Created
July 11, 2022 21:04
-
-
Save andrewvc/389e53061a7fd045671556d304f65b08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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