Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: replace jest with mocha #14054

Merged
merged 128 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
e15d486
initial. external snapshots
connorjclark Nov 17, 2021
b57b6d6
inline snapshot
connorjclark Nov 17, 2021
5f1f6be
one snapshot state per test file
connorjclark Nov 18, 2021
2bd3231
maintain map of snapshot states by test file
connorjclark Nov 18, 2021
f92351a
simplify
connorjclark Nov 18, 2021
e10c0ac
use testdouble to mock modules
connorjclark Nov 23, 2021
2f7f891
yarn unit-cli-mocha mostly works
connorjclark Nov 23, 2021
c4d591b
comment
connorjclark Nov 23, 2021
d4d4830
Merge remote-tracking branch 'origin/master' into mocha
connorjclark Jan 13, 2022
5b2b8b0
fix beforeAll/afterAll timeouts
connorjclark Jan 13, 2022
5b03510
fix config test
connorjclark Jan 13, 2022
b553be9
update
connorjclark Jan 13, 2022
e7eb722
fix types
connorjclark Jan 13, 2022
8f8eaea
update
connorjclark Jan 13, 2022
b084502
ci
connorjclark Jan 13, 2022
939e1d0
todo, rm log
connorjclark Jan 13, 2022
dbb8e60
comment
connorjclark Jan 13, 2022
2b3e56b
patch mocha globals
connorjclark Jan 13, 2022
4f96ce4
dev
connorjclark Jan 13, 2022
d00d94a
typecheck
connorjclark Jan 13, 2022
071ae8e
update
connorjclark Jan 13, 2022
b311566
update
connorjclark Jan 13, 2022
71198a5
Merge remote-tracking branch 'origin/master' into mocha
connorjclark Feb 7, 2022
0cebb33
print instruction on snapshot failure
connorjclark Feb 7, 2022
7f0a250
run-tests.js
connorjclark Feb 7, 2022
1092625
update snapshhots
connorjclark Feb 7, 2022
9bea135
Merge remote-tracking branch 'origin/master' into mocha
connorjclark May 17, 2022
7e3912d
update testdouble and rm hacky workaround
connorjclark May 17, 2022
e4d3a62
--testMatch
connorjclark May 17, 2022
b3c9ecf
update
connorjclark May 17, 2022
39eef45
gitignore
connorjclark May 17, 2022
4cff085
mochaPassThruArgs
connorjclark May 17, 2022
8eedc78
ok
connorjclark May 17, 2022
6656a0b
--parallel
connorjclark May 17, 2022
74336c5
yml
connorjclark May 17, 2022
c8c69a0
lint
connorjclark May 17, 2022
3a1908f
convert report tests to mocha
connorjclark May 17, 2022
b497806
add custom expect matchers to mocha
connorjclark May 17, 2022
8ab1d52
filter based on abs path
connorjclark May 17, 2022
ab2297f
wip: core tests
connorjclark May 17, 2022
e39e177
tests: use readJson instead of imports for json
connorjclark May 17, 2022
8272d98
runner test working because fake jest global
connorjclark May 18, 2022
ac081ca
rm jest global imports
connorjclark May 18, 2022
34d7888
more cool stuff
connorjclark May 18, 2022
dc11c5d
most core tests working now. rm dum jest global
connorjclark May 19, 2022
e7849cb
parallel comment
connorjclark May 19, 2022
bb0a88a
reset global state between test suites
connorjclark May 19, 2022
e54067b
symlink lighthouse-plugin-simple in global fixture
connorjclark May 19, 2022
bffe102
meh
connorjclark May 19, 2022
86f8e2f
Merge remote-tracking branch 'origin/master' into mocha-core
connorjclark May 19, 2022
7363822
fix mockRunnerModule
connorjclark May 19, 2022
c9a80a9
fix mockTargetManagerModule
connorjclark May 19, 2022
f261726
fix silly mocking in gather-runner-test that was breaking other tests
connorjclark May 19, 2022
07e5b2d
fix asset saver test tmp file location
connorjclark May 20, 2022
09a8ced
fix very bad no good process mock
connorjclark May 20, 2022
e9942fe
isolate some tests
connorjclark May 20, 2022
f4c4959
fake-timers.js
connorjclark May 20, 2022
616984a
work out what tests need to be isolated
connorjclark May 20, 2022
4342499
update mocha
connorjclark May 21, 2022
6dc9c15
rm old comment
connorjclark May 21, 2022
3ad00bc
oops
connorjclark May 21, 2022
e3598e4
comment
connorjclark May 21, 2022
51b8f58
save some tmp files in better place by default
connorjclark May 21, 2022
1c5bbb9
wip
connorjclark May 21, 2022
dd40267
Merge remote-tracking branch 'origin/master' into mocha-core
connorjclark May 21, 2022
90052bc
failfast
connorjclark May 23, 2022
150cdea
ugh
connorjclark May 23, 2022
8c473e9
fix
connorjclark May 24, 2022
565c242
Merge remote-tracking branch 'origin/master' into mocha-core
connorjclark May 24, 2022
ef4f724
Merge branch 'mocha-report' into mocha-final
connorjclark May 24, 2022
af9a078
other folders
connorjclark May 24, 2022
389fa33
wip flow-repor
connorjclark May 24, 2022
e4f3307
flow-report/test mostly working
connorjclark May 24, 2022
a85ec33
improve flow report test script
connorjclark May 25, 2022
cd50b31
upgrade @testing-library/preact
connorjclark May 25, 2022
fcb91e6
do not need those h imports
connorjclark May 25, 2022
430cc49
dont need h at all
connorjclark May 25, 2022
049b2fe
delete jest
connorjclark May 25, 2022
2b4a7a0
remove beforeAll/afterAll and use mocha before/after
connorjclark May 25, 2022
19050b5
eslint global expect
connorjclark May 25, 2022
2d2bcd0
fix yarn test-docs
connorjclark May 25, 2022
a01d8f6
simplify outDir in tsconfig files
brendankenny May 25, 2022
f93ae0c
typescript@4.6.4
brendankenny May 25, 2022
dadbe1b
global expect for ts tests
connorjclark May 25, 2022
9010203
fix expect types augmentation
connorjclark May 25, 2022
05193d3
misc
connorjclark May 25, 2022
aed971c
typescript@^4.7.2
brendankenny May 25, 2022
bb99f1c
more fixes
connorjclark May 25, 2022
46464a0
no more jest
connorjclark May 25, 2022
60a3e1d
test-env folder. fix flow-report hack
connorjclark May 25, 2022
1b5c356
redo yarn lock
connorjclark May 25, 2022
155c6df
fix expect imports
connorjclark May 25, 2022
76190f2
fix cli tests
connorjclark May 25, 2022
1c48d28
isolate scenario tests
connorjclark May 25, 2022
5bb8c0e
-t options
connorjclark May 25, 2022
ecbfd5c
fix timer import
connorjclark May 25, 2022
19079fb
trying to get topbar test working...
connorjclark May 26, 2022
8100b52
comment
connorjclark May 26, 2022
7316980
update
connorjclark May 26, 2022
53ae5fb
uhhh ok
connorjclark May 26, 2022
c55da8b
set outdir of base tsconfig so flow report test doesnt make fake-time…
connorjclark May 26, 2022
197e849
improve dx for failing tests
connorjclark May 26, 2022
7e4d609
undo
connorjclark May 26, 2022
8834548
Merge remote-tracking branch 'origin/tsc-4.7' into mocha-final
connorjclark May 26, 2022
a8fb4fc
Merge remote-tracking branch 'origin/master' into mocha-final
connorjclark May 31, 2022
3a23f0c
Merge remote-tracking branch 'origin/master' into mocha-final
connorjclark Jun 1, 2022
87df3d6
update
connorjclark Jun 1, 2022
819cd3e
Merge remote-tracking branch 'origin/master' into mocha-final
connorjclark Jun 8, 2022
4a5241b
implement --onlyFailures
connorjclark Jun 8, 2022
9d52b2f
try upgrading c8
connorjclark Jun 8, 2022
7986440
lock
connorjclark Jun 8, 2022
cd4a6b2
Merge remote-tracking branch 'origin/master' into mocha-final
connorjclark Jun 10, 2022
e4ea822
update
connorjclark Jun 17, 2022
c5db0fb
Merge remote-tracking branch 'origin/master' into mocha-final
connorjclark Jun 17, 2022
2fd6c44
fix
connorjclark Jun 17, 2022
1cc6460
Merge remote-tracking branch 'origin/master' into mocha-final
connorjclark Jun 27, 2022
78bdc2d
update isolated tests
connorjclark Jun 27, 2022
d4ac04f
update
connorjclark Jun 29, 2022
a0b10d4
pr
connorjclark Jun 29, 2022
b8c8f8c
hmm
connorjclark Jun 29, 2022
3e168e0
fail zero ci
connorjclark Jun 29, 2022
e6ac2b6
timeout
connorjclark Jun 29, 2022
7c5fb8f
rm single quotes to fix windows
connorjclark Jun 29, 2022
6c2bb68
use node as file
connorjclark Jun 29, 2022
68b86ef
npx
connorjclark Jun 29, 2022
d49d996
shell
connorjclark Jun 29, 2022
0683edc
ugh
connorjclark Jun 29, 2022
9195096
wip
connorjclark Jun 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# Ex: bash jest-retry.sh yarn test-viewer
# Ex: bash test-retry.sh yarn test-viewer

##
# @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ jobs:
# Run tests that require headfull Chrome.
- run: sudo apt-get install xvfb
- name: yarn test-clients
run: xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/.github/scripts/jest-retry.sh yarn test-clients
run: xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/.github/scripts/test-retry.sh yarn test-clients
- name: yarn test-docs
run: xvfb-run --auto-servernum yarn test-docs
- name: yarn test-viewer
run: xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/.github/scripts/jest-retry.sh yarn test-viewer
run: xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/.github/scripts/test-retry.sh yarn test-viewer
- name: yarn test-treemap
run: xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/.github/scripts/jest-retry.sh yarn test-treemap
run: xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/.github/scripts/test-retry.sh yarn test-treemap

- run: yarn diff:sample-json
- run: yarn diff:flow-sample-json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cron-weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
node-version: 14.x
- run: yarn --frozen-lockfile

- run: yarn jest --testMatch="**/third-party/chromium-synchronization/*-test.js"
- run: yarn mocha --testMatch=third-party/chromium-synchronization/*-test.js
6 changes: 3 additions & 3 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
run: xvfb-run --auto-servernum yarn unit:ci

# Only gather coverage on latest node, where c8 is the most accurate.
- name: yarn unit:coverage
- name: yarn unit:cicoverage
if: ${{ matrix.node == env.LATEST_NODE }}
run: |
xvfb-run --auto-servernum yarn unit:cicoverage
Expand Down Expand Up @@ -91,8 +91,8 @@ jobs:
- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn build-report

- name: yarn unit-cli
run: yarn unit-cli
# TODO: fix run-mocha-tests.js on windows.
# - run: yarn unit-cli
- run: yarn diff:sample-json

# Fail if any changes were written to any source files or generated untracked files (ex, from -GA).
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ lcov.info
lighthouse-cli/results
results.html
last-run-results.html
/lighthouse-plugin-simple

*.trace.json
*.devtoolslog.json
Expand Down
5 changes: 4 additions & 1 deletion build/test/plugins/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

module.exports = {
env: {
jest: true,
mocha: true,
},
globals: {
expect: true,
},
};
5 changes: 4 additions & 1 deletion clients/test/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

module.exports = {
env: {
jest: true,
mocha: true,
},
globals: {
expect: true,
},
};
4 changes: 2 additions & 2 deletions clients/test/extension/popup-test-pptr.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Lighthouse chrome popup', function() {
let page;
const pageErrors = [];

beforeAll(async function() {
before(async function() {
// start puppeteer
browser = await puppeteer.launch({
headless: false,
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('Lighthouse chrome popup', function() {
await page.goto('file://' + path.join(lighthouseExtensionPath, 'popup.html'), {waitUntil: 'networkidle2'});
}, 10 * 1000);

afterAll(async () => {
after(async () => {
if (browser) {
await browser.close();
}
Expand Down
14 changes: 7 additions & 7 deletions clients/test/lightrider/lightrider-entry-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

import {jest} from '@jest/globals';
import jestMock from 'jest-mock';
import {strict as assert} from 'assert';
import {runLighthouseInLR} from '../../lightrider/lightrider-entry.js';
import Runner from '../../../lighthouse-core/runner.js';
Expand Down Expand Up @@ -58,7 +58,7 @@ describe('lightrider-entry', () => {
});

it('specifies the channel as lr', async () => {
const runStub = jest.spyOn(Runner, 'gather');
const runStub = jestMock.spyOn(Runner, 'gather');

const mockConnection = {};
const url = 'https://example.com';
Expand All @@ -71,7 +71,7 @@ describe('lightrider-entry', () => {
});

it('uses the desktop config preset when device is desktop', async () => {
const runStub = jest.spyOn(Runner, 'gather');
const runStub = jestMock.spyOn(Runner, 'gather');

const mockConnection = {};
const url = 'https://example.com';
Expand All @@ -85,7 +85,7 @@ describe('lightrider-entry', () => {
});

it('uses the mobile config preset when device is mobile', async () => {
const runStub = jest.spyOn(Runner, 'gather');
const runStub = jestMock.spyOn(Runner, 'gather');

const mockConnection = {};
const url = 'https://example.com';
Expand All @@ -99,7 +99,7 @@ describe('lightrider-entry', () => {
});

it('overrides the default config when one is provided', async () => {
const runStub = jest.spyOn(Runner, 'gather');
const runStub = jestMock.spyOn(Runner, 'gather');

const mockConnection = {};
const url = 'https://example.com';
Expand Down Expand Up @@ -127,8 +127,8 @@ describe('lightrider-entry', () => {
});

it('exposes artifacts when logAssets is true', async () => {
Runner.gather = jest.fn();
Runner.audit = jest.fn(Runner.audit).mockReturnValue(Promise.resolve({
Runner.gather = jestMock.fn();
Runner.audit = jestMock.fn(Runner.audit).mockReturnValue(Promise.resolve({
lhr: {},
artifacts: {
Artifact: new Error('some error'),
Expand Down
5 changes: 4 additions & 1 deletion docs/recipes/auth/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
module.exports = {
extends: '../../../.eslintrc.js',
env: {
jest: true,
mocha: true,
},
globals: {
expect: true,
},
rules: {
'new-cap': 0,
Expand Down
2 changes: 1 addition & 1 deletion docs/recipes/integration-test/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

module.exports = {
env: {
jest: true,
mocha: true,
},
};
14 changes: 0 additions & 14 deletions docs/recipes/integration-test/docs-jest.config.js

This file was deleted.

9 changes: 4 additions & 5 deletions docs/recipes/integration-test/example-lh-auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@
/* eslint-disable new-cap */

/**
* @fileoverview Example Jest tests for demonstrating how to run Lighthouse on an authenticated
* @fileoverview Example Mocha tests for demonstrating how to run Lighthouse on an authenticated
* page as integration tests. See docs/recipes/auth/README.md for more.
*/

/** @typedef {import('lighthouse/types/lhr')} LH */

const puppeteer = require('puppeteer');
const lighthouse = require('lighthouse');
const {expect} = require('expect');
connorjclark marked this conversation as resolved.
Show resolved Hide resolved
const server = require('../auth/server/server.js');
const {login, logout} = require('../auth/example-lh-auth.js');

const CHROME_DEBUG_PORT = 8042;
const SERVER_PORT = 10632;
const ORIGIN = `http://localhost:${SERVER_PORT}`;

jest.setTimeout(30000);

// Provide a nice way to assert a score for a category.
// Note, you could just use `expect(lhr.categories.seo.score).toBeGreaterThanOrEqual(0.9)`,
// but by using a custom matcher a better error report is generated.
Expand Down Expand Up @@ -78,7 +77,7 @@ describe('my site', () => {
/** @type {import('puppeteer').Page} */
let page;

beforeAll(async () => {
before(async () => {
await new Promise(resolve => server.listen(SERVER_PORT, resolve));
browser = await puppeteer.launch({
args: [`--remote-debugging-port=${CHROME_DEBUG_PORT}`],
Expand All @@ -87,7 +86,7 @@ describe('my site', () => {
});
});

afterAll(async () => {
after(async () => {
await browser.close();
await new Promise(resolve => server.close(resolve));
});
Expand Down
4 changes: 2 additions & 2 deletions docs/recipes/integration-test/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"private": true,
"scripts": {
"test": "jest example-lh-auth.test.js"
"test": "mocha --timeout 30000 example-lh-auth.test.js"
},
"dependencies": {
"jest": "^24.9.0",
"mocha": "^10.0.0",
"lighthouse": "file:../../../dist/lighthouse.tgz"
}
}
4 changes: 2 additions & 2 deletions docs/recipes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"private": true,
"scripts": {
"install-all": "rm -rf /tmp/.junk && rm -f {auth,custom-gatherer-puppeteer,integration-test}/yarn.lock && yarn --cwd auth/ --cache-folder /tmp/.junk && yarn --cwd integration-test/ --cache-folder /tmp/.junk && yarn --cwd custom-gatherer-puppeteer/ --cache-folder /tmp/.junk",
"integration-test": "yarn --cwd integration-test/ jest --config-path=docs-jest.config.js",
"integration-test": "yarn --cwd integration-test/ test",
"custom-gatherer-puppeteer-test": "yarn --cwd custom-gatherer-puppeteer/ test",
"test": "yarn install-all && yarn integration-test && yarn custom-gatherer-puppeteer-test"
"test": "sh test-recipes.sh"
}
}
21 changes: 21 additions & 0 deletions docs/recipes/test-recipes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

##
# @license Copyright 2022 The Lighthouse Authors. 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.
##

set -eux

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"

# Locally, make sure dist/lighthouse.tgz is the latest code.
if [ -z "${CI:-}" ]; then
yarn --cwd ../.. build-pack
fi

yarn install-all
yarn integration-test
yarn custom-gatherer-puppeteer-test
10 changes: 6 additions & 4 deletions flow-report/test/common-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
* 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.
*/

import {jest} from '@jest/globals';
import jestMock from 'jest-mock';
import {act, render} from '@testing-library/preact';

// @ts-ignore: File is not under 'rootDir'
import {timers} from '../../lighthouse-core/test/test-env/fake-timers.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this could go in shared or something, but that already has a test folder and this is the only place we do this so it's probably fine.

Copy link
Collaborator Author

@connorjclark connorjclark May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving common test stuff to a common folder will be done sometime later.

import {FlowStepThumbnail} from '../src/common';

let lhr: LH.Result;

jest.useFakeTimers();
timers.useFakeTimers();

describe('FlowStepThumbnail', () => {
beforeEach(() => {
global.console.warn = jest.fn();
global.console.warn = jestMock.fn();

lhr = {
gatherMode: 'navigation',
Expand Down Expand Up @@ -97,7 +99,7 @@ describe('FlowStepThumbnail', () => {

expect(thumbnail.src).toContain('frame1');
await act(() => {
jest.advanceTimersByTime(501);
timers.advanceTimersByTime(501);
});
expect(thumbnail.src).toContain('frame2');
});
Expand Down
11 changes: 4 additions & 7 deletions flow-report/test/flow-report-pptr-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,34 @@
* 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.
*/

import {jest} from '@jest/globals';
import puppeteer, {Browser, Page} from 'puppeteer';

import ReportGenerator from '../../report/generator/report-generator.js';
import {flowResult} from './sample-flow';

jest.setTimeout(35_000);

describe('Lighthouse Flow Report', () => {
console.log('\n✨ Be sure to have recently run this: yarn build-report');

let browser: Browser;
let page: Page;
const pageErrors: Error[] = [];

beforeAll(async () => {
before(async () => {
browser = await puppeteer.launch({
headless: true,
});
page = await browser.newPage();
page.on('pageerror', pageError => pageErrors.push(pageError));
});

afterAll(async () => {
after(async () => {
if (pageErrors.length > 0) console.error(pageErrors);

await browser.close();
});

describe('Renders the flow report', () => {
beforeAll(async () => {
before(async () => {
const html = ReportGenerator.generateFlowReportHtml(flowResult);
await page.setContent(html);
});
Expand All @@ -43,4 +40,4 @@ describe('Lighthouse Flow Report', () => {
expect(pageErrors).toHaveLength(0);
});
});
});
}).timeout(35_000);
20 changes: 20 additions & 0 deletions flow-report/test/run-flow-report-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

##
# @license Copyright 2022 The Lighthouse Authors. 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.
##

set -eux

ARGS=(
--testMatch='{flow-report/**/*-test.ts,flow-report/**/*-test.tsx}'
--require=flow-report/test/setup/env-setup.ts
--loader=@esbuild-kit/esm-loader
# util-test.tsx won't finish on its own because of an open MessagePort, so help it out.
# See https://github.com/jsdom/jsdom/issues/2448#issuecomment-802288244
--exit
)

yarn mocha ${ARGS[*]} "$@"
adamraine marked this conversation as resolved.
Show resolved Hide resolved
Loading