Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore(jest): convert browser tests to jest (#3000)
Joel Einbinderdf8b27069e8e
diff --git a/test/browser.spec.js b/test/browser.jest.jssimilarity index 94%rename from test/browser.spec.jsrename to test/browser.jest.jsindex 3047c71621..445fc22347 100644--- a/test/browser.spec.js+++ b/test/browser.jest.js@@ -14,7 +14,7 @@* limitations under the License.*/-const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);+const {FFOX, CHROMIUM, WEBKIT} = testOptions;describe('Browser.newPage', function() {it('should create new page', async function({browser}) {diff --git a/test/browsercontext.spec.js b/test/browsercontext.jest.jssimilarity index 99%rename from test/browsercontext.spec.jsrename to test/browsercontext.jest.jsindex 13253f6ae9..73939805ab 100644--- a/test/browsercontext.spec.js+++ b/test/browsercontext.jest.js@@ -16,7 +16,8 @@*/const utils = require('./utils');-const {FFOX, CHROMIUM, WEBKIT, MAC, CHANNEL} = utils.testOptions(browserType);+const {FFOX, CHROMIUM, WEBKIT, MAC, CHANNEL, HEADLESS} = testOptions;+const {devices} = require('..');describe('BrowserContext', function() {it('should create new context', async function({browser}) {@@ -194,7 +195,7 @@ describe('BrowserContext({userAgent})', function() {await context.close();}{- const context = await browser.newContext({ userAgent: playwright.devices['iPhone 6'].userAgent });+ const context = await browser.newContext({ userAgent: devices['iPhone 6'].userAgent });const page = await context.newPage();await page.goto(server.PREFIX + '/mobile.html');expect(await page.evaluate(() => navigator.userAgent)).toContain('iPhone');diff --git a/test/channels.spec.js b/test/channels.jest.jssimilarity index 98%rename from test/channels.spec.jsrename to test/channels.jest.jsindex 950266a84b..7873efc8b4 100644--- a/test/channels.spec.js+++ b/test/channels.jest.js@@ -15,7 +15,7 @@* limitations under the License.*/-const { FFOX, CHROMIUM, WEBKIT, WIN, CHANNEL } = require('./utils').testOptions(browserType);+const { FFOX, CHROMIUM, WEBKIT, WIN, CHANNEL } = testOptions;describe.skip(!CHANNEL)('Channels', function() {it('should work', async({browser}) => {diff --git a/test/ignorehttpserrors.spec.js b/test/ignorehttpserrors.jest.jssimilarity index 97%rename from test/ignorehttpserrors.spec.jsrename to test/ignorehttpserrors.jest.jsindex 5657ae22fb..3c83091844 100644--- a/test/ignorehttpserrors.spec.js+++ b/test/ignorehttpserrors.jest.js@@ -15,7 +15,7 @@* limitations under the License.*/-const {FFOX, CHROMIUM, WEBKIT, MAC} = require('./utils').testOptions(browserType);+const {FFOX, CHROMIUM, WEBKIT, MAC} = testOptions;describe('ignoreHTTPSErrors', function() {it('should work', async({browser, httpsServer}) => {diff --git a/test/popup.spec.js b/test/popup.jest.jssimilarity index 99%rename from test/popup.spec.jsrename to test/popup.jest.jsindex a142dd3458..fe0f00aa85 100644--- a/test/popup.spec.js+++ b/test/popup.jest.js@@ -14,7 +14,7 @@* limitations under the License.*/-const {FFOX, CHROMIUM, WEBKIT, MAC} = require('./utils').testOptions(browserType);+const {FFOX, CHROMIUM, WEBKIT, MAC} = testOptions;describe('Link navigation', function() {it('should inherit user agent from browser context', async function({browser, server}) {diff --git a/test/test.config.js b/test/test.config.jsindex 3a76858f63..65cf323a8d 100644--- a/test/test.config.js+++ b/test/test.config.js@@ -99,17 +99,6 @@ module.exports = {environments: [customEnvironment, 'page'],},- {- files: [- './browser.spec.js',- './browsercontext.spec.js',- './channels.spec.js',- './ignorehttpserrors.spec.js',- './popup.spec.js',- ],- environments: [customEnvironment, 'browser'],- },-{files: ['./defaultbrowsercontext.spec.js',diff --git a/test/test.js b/test/test.jsindex cde1db4453..6e7ea45a40 100644--- a/test/test.js+++ b/test/test.js@@ -127,9 +127,7 @@ function collect(browserNames) {const skip = spec.browsers && !spec.browsers.includes(browserName);(skip ? xdescribe : describe)(spec.title || '', () => {for (const e of spec.environments || ['page']) {- if (e === 'browser') {- testRunner.collector().useEnvironment(browserEnvironment);- } else if (e === 'page') {+ if (e === 'page') {testRunner.collector().useEnvironment(browserEnvironment);testRunner.collector().useEnvironment(pageEnvironment);} else {