Skip to content

Instantly share code, notes, and snippets.

@estruyf
Last active February 27, 2020 17:45
Show Gist options
  • Select an option

  • Save estruyf/30329c788aea4d92a8178d97905c5922 to your computer and use it in GitHub Desktop.

Select an option

Save estruyf/30329c788aea4d92a8178d97905c5922 to your computer and use it in GitHub Desktop.
Playwright with Jest for E2E testing - samples 1
const playwright = require('playwright');
const PAGE_URL = "https://www.eliostruyf.com";
describe(`UI Tests with Playwright`, () => {
let browser = null;
let page = null;
/**
* Create the browser and page context
*/
beforeAll(async () => {
browser = await playwright["chromium"].launch();
page = await browser.newPage();
if (!page) {
throw new Error("Connection wasn't established");
}
// Open the page
await page.goto(PAGE_URL, {
waitUntil: "networkidle0"
});
});
afterAll(async () => {
await browser.close();
});
test(`Should load page`, async () => {
expect(page).not.toBeNull();
expect(await page.title()).not.toBeNull();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment