chore: fix chrome-headless ci (#8560)

This commit is contained in:
Alex Rudenko 2022-06-27 12:35:09 +02:00 committed by GitHub
parent e499515fd6
commit 329195011f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 22 deletions

View File

@ -183,9 +183,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
# Include active LTS + current Node.js version.
# Include a current Node.js version.
# https://github.com/nodejs/Release#release-schedule
node: [16, 18]
node: [18]
steps:
- name: Checkout
uses: actions/checkout@v3
@ -209,7 +209,6 @@ jobs:
npm run build
- name: Run unit tests in headful mode
uses: nick-invision/retry@v2
continue-on-error: true
env:
CHROMIUM: true
HEADLESS: false
@ -218,15 +217,14 @@ jobs:
command: xvfb-run --auto-servernum npm run test:unit
timeout_minutes: 10
chrome-headless:
linux-chrome-headless:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# https://github.com/actions/virtual-environments#available-environments
os: [ubuntu-latest, macos-latest, windows-latest]
# Include active LTS + current Node.js version.
os: [ubuntu-latest]
# https://github.com/nodejs/Release#release-schedule
node: [16, 18]
node: [18]
steps:
- name: Checkout
uses: actions/checkout@v3
@ -238,17 +236,19 @@ jobs:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: |
sudo apt-get install xvfb
# Ensure both a Chromium and a Firefox binary are available.
PUPPETEER_PRODUCT=firefox npm install
npm install
ls .local-chromium
ls .local-chromium .local-firefox
- name: Build
run: |
npm run build
- name: Run unit tests
uses: nick-invision/retry@v2
continue-on-error: true
env:
CHROMIUM: true
with:
max_attempts: 1
command: npm run test:unit:chrome-headless
timeout_minutes: 30
command: xvfb-run --auto-servernum npm run test:unit:chrome-headless
timeout_minutes: 10

View File

@ -22,8 +22,12 @@ import {getTestState, itHeadlessOnly} from './mocha-utils.js';
import path from 'path';
describe('Fixtures', function () {
itHeadlessOnly('dumpio option should work with pipe option ', async () => {
const {defaultBrowserOptions, puppeteerPath} = getTestState();
itHeadlessOnly('dumpio option should work with pipe option', async () => {
const {defaultBrowserOptions, puppeteerPath, headless} = getTestState();
if (headless === 'chrome') {
// This test only works in the old headless mode.
return;
}
let dumpioData = '';
const {spawn} = await import('child_process');

View File

@ -160,15 +160,20 @@ describe('navigation', function () {
}
});
/* If you are running this on pre-Catalina versions of macOS this will fail locally.
/* Mac OSX Catalina outputs a different message than other platforms.
* See https://support.google.com/chrome/thread/18125056?hl=en for details.
* If you're running pre-Catalina Mac OSX this test will fail locally.
*/
const EXPECTED_SSL_CERT_MESSAGE =
os.platform() === 'darwin'
function getExpectedSSLCertMessage(): string {
const {headless} = getTestState();
/**
* If you are running this on pre-Catalina versions of macOS this will fail
* locally. Mac OSX Catalina outputs a different message than other
* platforms. See https://support.google.com/chrome/thread/18125056?hl=en
* for details. If you're running pre-Catalina Mac OSX this test will fail
* locally.
* In chrome-headless, the message is also different.
*/
return os.platform() === 'darwin' && headless !== 'chrome'
? 'net::ERR_CERT_INVALID'
: 'net::ERR_CERT_AUTHORITY_INVALID';
}
itFailsFirefox('should fail when navigating to bad SSL', async () => {
const {page, httpsServer, isChrome} = getTestState();
@ -191,7 +196,7 @@ describe('navigation', function () {
return (error = error_);
});
if (isChrome) {
expect(error.message).toContain(EXPECTED_SSL_CERT_MESSAGE);
expect(error.message).toContain(getExpectedSSLCertMessage());
} else {
expect(error.message).toContain('SSL_ERROR_UNKNOWN');
}
@ -210,7 +215,7 @@ describe('navigation', function () {
return (error = error_);
});
if (isChrome) {
expect(error.message).toContain(EXPECTED_SSL_CERT_MESSAGE);
expect(error.message).toContain(getExpectedSSLCertMessage());
} else {
expect(error.message).toContain('SSL_ERROR_UNKNOWN');
}