mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore(ci): re-enable tests on Windows (#5637)
* chore: Add Windows to Travis This commit runs the unit tests on Windows. There are two tests failing on Windows that we skip. I spoke to Mathias B and we agreed to defer debugging this for now in favour of getting tests running on Windows. But we didn't want to ignore it forever, hence giving the test a date at which it will start to fail.
This commit is contained in:
parent
49ca00f16a
commit
c4fe4e46c2
11
.travis.yml
11
.travis.yml
@ -13,6 +13,17 @@ cache:
|
|||||||
- node_modules
|
- node_modules
|
||||||
jobs:
|
jobs:
|
||||||
include:
|
include:
|
||||||
|
- os: "windows"
|
||||||
|
node_js: "10.19.0"
|
||||||
|
env:
|
||||||
|
- CHROMIUM=true
|
||||||
|
before_install:
|
||||||
|
# populate .local-firefox for launcher tests
|
||||||
|
- PUPPETEER_PRODUCT=firefox npm install
|
||||||
|
script:
|
||||||
|
- ls .local-chromium .local-firefox
|
||||||
|
- npm run tsc
|
||||||
|
- npm run unit
|
||||||
- node_js: "10.19.0"
|
- node_js: "10.19.0"
|
||||||
dist: trusty
|
dist: trusty
|
||||||
env:
|
env:
|
||||||
|
@ -1,8 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2020 Google Inc. All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const os = require('os');
|
||||||
const base = require('./base');
|
const base = require('./base');
|
||||||
|
|
||||||
|
const longerTimeoutRequired = process.env.PUPPETEER_PRODUCT === 'firefox' || os.platform() === 'win32';
|
||||||
|
|
||||||
|
const timeout = longerTimeoutRequired ? 25 * 1000 : 10 * 1000;
|
||||||
|
|
||||||
|
console.log('Mocha config: Timeout set to', timeout / 1000, 'seconds');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
...base,
|
...base,
|
||||||
file: ['./test/mocha-utils.js'],
|
file: ['./test/mocha-utils.js'],
|
||||||
spec: 'test/*.spec.js',
|
spec: 'test/*.spec.js',
|
||||||
timeout: process.env.PUPPETEER_PRODUCT === 'firefox' ? 15 * 1000 : 10 * 1000,
|
timeout,
|
||||||
};
|
};
|
||||||
|
@ -85,26 +85,33 @@ describeChromeOnly('headful tests', function() {
|
|||||||
expect(pages).toEqual(['about:blank']);
|
expect(pages).toEqual(['about:blank']);
|
||||||
await browser.close();
|
await browser.close();
|
||||||
});
|
});
|
||||||
it('headless should be able to read cookies written by headful', async() => {
|
itFailsWindowsUntilDate(
|
||||||
const { server, puppeteer } = getTestState();
|
/* We have deferred fixing this test on Windows in favour of
|
||||||
|
* getting all other Windows tests running on CI. Putting this
|
||||||
|
* date in to force us to come back and debug properly in the
|
||||||
|
* future.
|
||||||
|
*/
|
||||||
|
new Date('2020-06-01'),
|
||||||
|
'headless should be able to read cookies written by headful', async() => {
|
||||||
|
const { server, puppeteer } = getTestState();
|
||||||
|
|
||||||
const userDataDir = await mkdtempAsync(TMP_FOLDER);
|
const userDataDir = await mkdtempAsync(TMP_FOLDER);
|
||||||
// Write a cookie in headful chrome
|
// Write a cookie in headful chrome
|
||||||
const headfulBrowser = await puppeteer.launch(Object.assign({userDataDir}, headfulOptions));
|
const headfulBrowser = await puppeteer.launch(Object.assign({userDataDir}, headfulOptions));
|
||||||
const headfulPage = await headfulBrowser.newPage();
|
const headfulPage = await headfulBrowser.newPage();
|
||||||
await headfulPage.goto(server.EMPTY_PAGE);
|
await headfulPage.goto(server.EMPTY_PAGE);
|
||||||
await headfulPage.evaluate(() => document.cookie = 'foo=true; expires=Fri, 31 Dec 9999 23:59:59 GMT');
|
await headfulPage.evaluate(() => document.cookie = 'foo=true; expires=Fri, 31 Dec 9999 23:59:59 GMT');
|
||||||
await headfulBrowser.close();
|
await headfulBrowser.close();
|
||||||
// Read the cookie from headless chrome
|
// Read the cookie from headless chrome
|
||||||
const headlessBrowser = await puppeteer.launch(Object.assign({userDataDir}, headlessOptions));
|
const headlessBrowser = await puppeteer.launch(Object.assign({userDataDir}, headlessOptions));
|
||||||
const headlessPage = await headlessBrowser.newPage();
|
const headlessPage = await headlessBrowser.newPage();
|
||||||
await headlessPage.goto(server.EMPTY_PAGE);
|
await headlessPage.goto(server.EMPTY_PAGE);
|
||||||
const cookie = await headlessPage.evaluate(() => document.cookie);
|
const cookie = await headlessPage.evaluate(() => document.cookie);
|
||||||
await headlessBrowser.close();
|
await headlessBrowser.close();
|
||||||
// This might throw. See https://github.com/puppeteer/puppeteer/issues/2778
|
// This might throw. See https://github.com/puppeteer/puppeteer/issues/2778
|
||||||
await rmAsync(userDataDir).catch(e => {});
|
await rmAsync(userDataDir).catch(e => {});
|
||||||
expect(cookie).toBe('foo=true');
|
expect(cookie).toBe('foo=true');
|
||||||
});
|
});
|
||||||
// TODO: Support OOOPIF. @see https://github.com/puppeteer/puppeteer/issues/2548
|
// TODO: Support OOOPIF. @see https://github.com/puppeteer/puppeteer/issues/2548
|
||||||
xit('OOPIF: should report google.com frame', async() => {
|
xit('OOPIF: should report google.com frame', async() => {
|
||||||
const { server } = getTestState();
|
const { server } = getTestState();
|
||||||
|
@ -353,6 +353,7 @@ describe('Launcher specs', function() {
|
|||||||
await browser.close();
|
await browser.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Puppeteer.launch', function() {
|
describe('Puppeteer.launch', function() {
|
||||||
let productName;
|
let productName;
|
||||||
|
|
||||||
@ -367,21 +368,28 @@ describe('Launcher specs', function() {
|
|||||||
puppeteer._productName = productName;
|
puppeteer._productName = productName;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to launch different products', async() => {
|
it('should be able to launch Chrome', async() => {
|
||||||
const {puppeteer} = getTestState();
|
const {puppeteer} = getTestState();
|
||||||
|
const browser = await puppeteer.launch({product: 'chrome'});
|
||||||
|
const userAgent = await browser.userAgent();
|
||||||
|
await browser.close();
|
||||||
|
expect(userAgent).toContain('Chrome');
|
||||||
|
});
|
||||||
|
|
||||||
const products = ['firefox', 'chrome'];
|
/* We think there's a bug in the FF Windows launcher, or some
|
||||||
for (const product of products) {
|
* combo of that plus it running on CI, but we're deferring fixing
|
||||||
const browser = await puppeteer.launch({product});
|
* this so we can get Windows CI stable and then dig into this
|
||||||
const userAgent = await browser.userAgent();
|
* properly with help from the Mozilla folks.
|
||||||
await browser.close();
|
*/
|
||||||
if (product === 'chrome')
|
itFailsWindowsUntilDate(new Date('2020-06-01'), 'should be able to launch Firefox', async() => {
|
||||||
expect(userAgent).toContain('Chrome');
|
const {puppeteer} = getTestState();
|
||||||
else
|
const browser = await puppeteer.launch({product: 'firefox'});
|
||||||
expect(userAgent).toContain('Firefox');
|
const userAgent = await browser.userAgent();
|
||||||
}
|
await browser.close();
|
||||||
|
expect(userAgent).toContain('Firefox');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Puppeteer.connect', function() {
|
describe('Puppeteer.connect', function() {
|
||||||
it('should be able to connect multiple times to the same browser', async() => {
|
it('should be able to connect multiple times to the same browser', async() => {
|
||||||
const { puppeteer, defaultBrowserOptions} = getTestState();
|
const { puppeteer, defaultBrowserOptions} = getTestState();
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
const {TestServer} = require('../utils/testserver/index');
|
const {TestServer} = require('../utils/testserver/index');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const os = require('os');
|
||||||
const puppeteer = require('../');
|
const puppeteer = require('../');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const assertCoverage = require('./coverage-utils');
|
const assertCoverage = require('./coverage-utils');
|
||||||
@ -92,6 +93,15 @@ global.itFailsFirefox = (...args) => {
|
|||||||
return it(...args);
|
return it(...args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
global.itFailsWindowsUntilDate = (date, ...args) => {
|
||||||
|
if (os.platform() === 'win32' && Date.now() < date) {
|
||||||
|
// we are within the deferred time so skip the test
|
||||||
|
return xit(...args);
|
||||||
|
}
|
||||||
|
|
||||||
|
return it(...args);
|
||||||
|
};
|
||||||
|
|
||||||
global.describeFailsFirefox = (...args) => {
|
global.describeFailsFirefox = (...args) => {
|
||||||
if (isFirefox)
|
if (isFirefox)
|
||||||
return xdescribe(...args);
|
return xdescribe(...args);
|
||||||
|
@ -189,7 +189,8 @@ describe('network', function() {
|
|||||||
const { page, server } = getTestState();
|
const { page, server } = getTestState();
|
||||||
|
|
||||||
const response = await page.goto(server.PREFIX + '/simple.json');
|
const response = await page.goto(server.PREFIX + '/simple.json');
|
||||||
expect(await response.text()).toBe('{"foo": "bar"}\n');
|
const responseText = (await response.text()).trimEnd();
|
||||||
|
expect(responseText).toBe('{"foo": "bar"}');
|
||||||
});
|
});
|
||||||
it('should return uncompressed text', async() => {
|
it('should return uncompressed text', async() => {
|
||||||
const { page, server } = getTestState();
|
const { page, server } = getTestState();
|
||||||
@ -197,7 +198,8 @@ describe('network', function() {
|
|||||||
server.enableGzip('/simple.json');
|
server.enableGzip('/simple.json');
|
||||||
const response = await page.goto(server.PREFIX + '/simple.json');
|
const response = await page.goto(server.PREFIX + '/simple.json');
|
||||||
expect(response.headers()['content-encoding']).toBe('gzip');
|
expect(response.headers()['content-encoding']).toBe('gzip');
|
||||||
expect(await response.text()).toBe('{"foo": "bar"}\n');
|
const responseText = (await response.text()).trimEnd();
|
||||||
|
expect(responseText).toBe('{"foo": "bar"}');
|
||||||
});
|
});
|
||||||
it('should throw when requesting body of redirected response', async() => {
|
it('should throw when requesting body of redirected response', async() => {
|
||||||
const { page, server } = getTestState();
|
const { page, server } = getTestState();
|
||||||
|
Loading…
Reference in New Issue
Block a user