-
Notifications
You must be signed in to change notification settings - Fork 9.6k
tests: replace jest with mocha #14054
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
Changes from 126 commits
e15d486
b57b6d6
5f1f6be
2bd3231
f92351a
e10c0ac
2f7f891
c4d591b
d4d4830
5b2b8b0
5b03510
b553be9
e7eb722
8f8eaea
b084502
939e1d0
dbb8e60
2b3e56b
4f96ce4
d00d94a
071ae8e
b311566
71198a5
0cebb33
7f0a250
1092625
9bea135
7e3912d
e4d3a62
b3c9ecf
39eef45
4cff085
8eedc78
6656a0b
74336c5
c8c69a0
3a1908f
b497806
8ab1d52
ab2297f
e39e177
8272d98
ac081ca
34d7888
dc11c5d
e7849cb
bb0a88a
e54067b
bffe102
86f8e2f
7363822
c9a80a9
f261726
07e5b2d
09a8ced
e9942fe
f4c4959
616984a
4342499
6dc9c15
3ad00bc
e3598e4
51b8f58
1c5bbb9
dd40267
90052bc
150cdea
8c473e9
565c242
ef4f724
af9a078
389fa33
e4f3307
a85ec33
cd50b31
fcb91e6
430cc49
049b2fe
2b4a7a0
19050b5
2d2bcd0
a01d8f6
f93ae0c
dadbe1b
9010203
05193d3
aed971c
bb99f1c
46464a0
60a3e1d
1b5c356
155c6df
76190f2
1c48d28
5bb8c0e
ecbfd5c
19079fb
8100b52
7316980
53ae5fb
c55da8b
197e849
7e4d609
8834548
a8fb4fc
3a23f0c
87df3d6
819cd3e
4a5241b
9d52b2f
7986440
cd4a6b2
e4ea822
c5db0fb
2fd6c44
1cc6460
78bdc2d
d4ac04f
a0b10d4
b8c8f8c
3e168e0
e6ac2b6
7c5fb8f
6c2bb68
68b86ef
d49d996
0683edc
9195096
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,9 @@ | |
|
|
||
| module.exports = { | ||
| env: { | ||
| jest: true, | ||
| mocha: true, | ||
| }, | ||
| globals: { | ||
| expect: true, | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,9 @@ | |
|
|
||
| module.exports = { | ||
| env: { | ||
| jest: true, | ||
| mocha: true, | ||
| }, | ||
| globals: { | ||
| expect: true, | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,6 @@ | |
|
|
||
| module.exports = { | ||
| env: { | ||
| jest: true, | ||
| mocha: true, | ||
| }, | ||
| }; | ||
This file was deleted.
| 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" | ||
| } | ||
| } |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally this could go in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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', | ||
|
|
@@ -97,7 +99,7 @@ describe('FlowStepThumbnail', () => { | |
|
|
||
| expect(thumbnail.src).toContain('frame1'); | ||
| await act(() => { | ||
| jest.advanceTimersByTime(501); | ||
| timers.advanceTimersByTime(501); | ||
| }); | ||
| expect(thumbnail.src).toContain('frame2'); | ||
| }); | ||
|
|
||
| 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
|
||
Uh oh!
There was an error while loading. Please reload this page.