Skip to content

Commit

Permalink
chore: fix chrome-headless ci (#8560)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Jun 27, 2022
1 parent e499515 commit 3291950
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
8 changes: 6 additions & 2 deletions test/src/fixtures.spec.ts
Expand Up @@ -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');
Expand Down
23 changes: 14 additions & 9 deletions test/src/navigation.spec.ts
Expand Up @@ -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();
Expand All @@ -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');
}
Expand All @@ -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');
}
Expand Down

0 comments on commit 3291950

Please sign in to comment.