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

View File

@ -22,8 +22,12 @@ import {getTestState, itHeadlessOnly} from './mocha-utils.js';
import path from 'path'; import path from 'path';
describe('Fixtures', function () { describe('Fixtures', function () {
itHeadlessOnly('dumpio option should work with pipe option ', async () => { itHeadlessOnly('dumpio option should work with pipe option', async () => {
const {defaultBrowserOptions, puppeteerPath} = getTestState(); const {defaultBrowserOptions, puppeteerPath, headless} = getTestState();
if (headless === 'chrome') {
// This test only works in the old headless mode.
return;
}
let dumpioData = ''; let dumpioData = '';
const {spawn} = await import('child_process'); 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. function getExpectedSSLCertMessage(): string {
/* Mac OSX Catalina outputs a different message than other platforms. const {headless} = getTestState();
* 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. * If you are running this on pre-Catalina versions of macOS this will fail
*/ * locally. Mac OSX Catalina outputs a different message than other
const EXPECTED_SSL_CERT_MESSAGE = * platforms. See https://support.google.com/chrome/thread/18125056?hl=en
os.platform() === 'darwin' * 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_INVALID'
: 'net::ERR_CERT_AUTHORITY_INVALID'; : 'net::ERR_CERT_AUTHORITY_INVALID';
}
itFailsFirefox('should fail when navigating to bad SSL', async () => { itFailsFirefox('should fail when navigating to bad SSL', async () => {
const {page, httpsServer, isChrome} = getTestState(); const {page, httpsServer, isChrome} = getTestState();
@ -191,7 +196,7 @@ describe('navigation', function () {
return (error = error_); return (error = error_);
}); });
if (isChrome) { if (isChrome) {
expect(error.message).toContain(EXPECTED_SSL_CERT_MESSAGE); expect(error.message).toContain(getExpectedSSLCertMessage());
} else { } else {
expect(error.message).toContain('SSL_ERROR_UNKNOWN'); expect(error.message).toContain('SSL_ERROR_UNKNOWN');
} }
@ -210,7 +215,7 @@ describe('navigation', function () {
return (error = error_); return (error = error_);
}); });
if (isChrome) { if (isChrome) {
expect(error.message).toContain(EXPECTED_SSL_CERT_MESSAGE); expect(error.message).toContain(getExpectedSSLCertMessage());
} else { } else {
expect(error.message).toContain('SSL_ERROR_UNKNOWN'); expect(error.message).toContain('SSL_ERROR_UNKNOWN');
} }