Skip to content

Instantly share code, notes, and snippets.

@estruyf
Created February 27, 2020 17:48
Show Gist options
  • Save estruyf/00e016772a01a4c9d2d50ef1865f7343 to your computer and use it in GitHub Desktop.
Save estruyf/00e016772a01a4c9d2d50ef1865f7343 to your computer and use it in GitHub Desktop.
Playwright with Jest for E2E testing - samples 2
const playwright = require('playwright');
const PAGE_URL = "https://www.eliostruyf.com";
// Loop over all the supported browsers
for (const browserType of ["chromium", "firefox", "webkit"]) {
describe(`(${browserType}): UI Tests with Playwright`, () => {
let browser = null;
let page = null;
/**
* Create the browser and page context
*/
beforeAll(async () => {
browser = await playwright[browserType].launch();
page = await browser.newPage();
if (!page) {
throw new Error("Connection wasn't established");
}
// Open the page
await page.goto(PAGE_URL, {
waitUntil: "networkidle0"
});
}, 10000);
afterAll(async () => {
await browser.close();
});
test(`(${browserType}): 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