Skip to content

Instantly share code, notes, and snippets.

@andrewvc
Created July 11, 2022 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewvc/389e53061a7fd045671556d304f65b08 to your computer and use it in GitHub Desktop.
Save andrewvc/389e53061a7fd045671556d304f65b08 to your computer and use it in GitHub Desktop.
import { journey, step, monitor, expect } from '@elastic/synthetics';
import { request } from 'playwright-core'
journey('My Example Journey', ({ page, params, context }) => {
// Only relevant for the push command to create
// monitors in Kibana
monitor.use({
id: 'example-monitor',
schedule: 15,
});
let title;
step('launch application', async () => {
const apiCtx = await request.newContext();
const resp = await apiCtx.get("https://jsonplaceholder.typicode.com/posts")
const body = JSON.parse((await resp.body()).toString())
title = body[0].title;
await page.goto(params.url);
});
step('assert title', async () => {
const header = await page.$('h1');
expect(await header.textContent()).toBe(title);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment