chore(jest): convert browser tests to jest (#3000)
This commit is contained in:
parent
1c0504ae28
commit
df8b27069e
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
|
||||||
|
|
||||||
describe('Browser.newPage', function() {
|
describe('Browser.newPage', function() {
|
||||||
it('should create new page', async function({browser}) {
|
it('should create new page', async function({browser}) {
|
||||||
|
|
@ -16,7 +16,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const utils = require('./utils');
|
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() {
|
describe('BrowserContext', function() {
|
||||||
it('should create new context', async function({browser}) {
|
it('should create new context', async function({browser}) {
|
||||||
|
|
@ -194,7 +195,7 @@ describe('BrowserContext({userAgent})', function() {
|
||||||
await context.close();
|
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();
|
const page = await context.newPage();
|
||||||
await page.goto(server.PREFIX + '/mobile.html');
|
await page.goto(server.PREFIX + '/mobile.html');
|
||||||
expect(await page.evaluate(() => navigator.userAgent)).toContain('iPhone');
|
expect(await page.evaluate(() => navigator.userAgent)).toContain('iPhone');
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* 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() {
|
describe.skip(!CHANNEL)('Channels', function() {
|
||||||
it('should work', async({browser}) => {
|
it('should work', async({browser}) => {
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const {FFOX, CHROMIUM, WEBKIT, MAC} = require('./utils').testOptions(browserType);
|
const {FFOX, CHROMIUM, WEBKIT, MAC} = testOptions;
|
||||||
|
|
||||||
describe('ignoreHTTPSErrors', function() {
|
describe('ignoreHTTPSErrors', function() {
|
||||||
it('should work', async({browser, httpsServer}) => {
|
it('should work', async({browser, httpsServer}) => {
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const {FFOX, CHROMIUM, WEBKIT, MAC} = require('./utils').testOptions(browserType);
|
const {FFOX, CHROMIUM, WEBKIT, MAC} = testOptions;
|
||||||
|
|
||||||
describe('Link navigation', function() {
|
describe('Link navigation', function() {
|
||||||
it('should inherit user agent from browser context', async function({browser, server}) {
|
it('should inherit user agent from browser context', async function({browser, server}) {
|
||||||
|
|
@ -99,17 +99,6 @@ module.exports = {
|
||||||
environments: [customEnvironment, 'page'],
|
environments: [customEnvironment, 'page'],
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
|
||||||
files: [
|
|
||||||
'./browser.spec.js',
|
|
||||||
'./browsercontext.spec.js',
|
|
||||||
'./channels.spec.js',
|
|
||||||
'./ignorehttpserrors.spec.js',
|
|
||||||
'./popup.spec.js',
|
|
||||||
],
|
|
||||||
environments: [customEnvironment, 'browser'],
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
{
|
||||||
files: [
|
files: [
|
||||||
'./defaultbrowsercontext.spec.js',
|
'./defaultbrowsercontext.spec.js',
|
||||||
|
|
|
||||||
|
|
@ -127,9 +127,7 @@ function collect(browserNames) {
|
||||||
const skip = spec.browsers && !spec.browsers.includes(browserName);
|
const skip = spec.browsers && !spec.browsers.includes(browserName);
|
||||||
(skip ? xdescribe : describe)(spec.title || '', () => {
|
(skip ? xdescribe : describe)(spec.title || '', () => {
|
||||||
for (const e of spec.environments || ['page']) {
|
for (const e of spec.environments || ['page']) {
|
||||||
if (e === 'browser') {
|
if (e === 'page') {
|
||||||
testRunner.collector().useEnvironment(browserEnvironment);
|
|
||||||
} else if (e === 'page') {
|
|
||||||
testRunner.collector().useEnvironment(browserEnvironment);
|
testRunner.collector().useEnvironment(browserEnvironment);
|
||||||
testRunner.collector().useEnvironment(pageEnvironment);
|
testRunner.collector().useEnvironment(pageEnvironment);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue