From df8b27069e8e45e6dd680b6bac8e4fd35b54a85e Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Fri, 17 Jul 2020 08:22:39 -0700 Subject: [PATCH] chore(jest): convert browser tests to jest (#3000) --- test/{browser.spec.js => browser.jest.js} | 2 +- ...{browsercontext.spec.js => browsercontext.jest.js} | 5 +++-- test/{channels.spec.js => channels.jest.js} | 2 +- ...ehttpserrors.spec.js => ignorehttpserrors.jest.js} | 2 +- test/{popup.spec.js => popup.jest.js} | 2 +- test/test.config.js | 11 ----------- test/test.js | 4 +--- 7 files changed, 8 insertions(+), 20 deletions(-) rename test/{browser.spec.js => browser.jest.js} (94%) rename test/{browsercontext.spec.js => browsercontext.jest.js} (99%) rename test/{channels.spec.js => channels.jest.js} (98%) rename test/{ignorehttpserrors.spec.js => ignorehttpserrors.jest.js} (97%) rename test/{popup.spec.js => popup.jest.js} (99%) diff --git a/test/browser.spec.js b/test/browser.jest.js similarity index 94% rename from test/browser.spec.js rename to test/browser.jest.js index 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.js similarity index 99% rename from test/browsercontext.spec.js rename to test/browsercontext.jest.js index 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.js similarity index 98% rename from test/channels.spec.js rename to test/channels.jest.js index 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.js similarity index 97% rename from test/ignorehttpserrors.spec.js rename to test/ignorehttpserrors.jest.js index 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.js similarity index 99% rename from test/popup.spec.js rename to test/popup.jest.js index 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.js index 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.js index 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 {