Skip to content

Commit e27ab6a

Browse files
authored
tests: finish removing mocha (#7429)
1 parent a3b9cf3 commit e27ab6a

File tree

8 files changed

+30
-166
lines changed

8 files changed

+30
-166
lines changed

clients/test/extension/extension-test.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
'use strict';
77

8-
/* eslint-env mocha */
8+
/* eslint-env jest */
99

1010
const path = require('path');
1111
const assert = require('assert');
@@ -49,10 +49,7 @@ describe('Lighthouse chrome extension', function() {
4949
});
5050
}
5151

52-
before(async function() {
53-
// eslint-disable-next-line
54-
this.timeout(90 * 1000);
55-
52+
beforeAll(async function() {
5653
// read original manifest
5754
originalManifest = fs.readFileSync(manifestLocation);
5855

@@ -108,9 +105,9 @@ describe('Lighthouse chrome extension', function() {
108105
extensionPage = (await browser.pages()).find(page =>
109106
page.url().includes('blob:chrome-extension://')
110107
);
111-
});
108+
}, 90 * 1000);
112109

113-
after(async () => {
110+
afterAll(async () => {
114111
// put the default manifest back
115112
fs.writeFileSync(manifestLocation, originalManifest);
116113

clients/test/extension/popup-test.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
'use strict';
77

8-
/* eslint-env mocha */
8+
/* eslint-env jest */
99

1010
const path = require('path');
1111
const assert = require('assert');
@@ -36,10 +36,7 @@ describe('Lighthouse chrome popup', function() {
3636
let page;
3737
const pageErrors = [];
3838

39-
before(async function() {
40-
// eslint-disable-next-line
41-
this.timeout(90 * 1000);
42-
39+
beforeAll(async function() {
4340
// start puppeteer
4441
browser = await puppeteer.launch({
4542
headless: false,
@@ -81,9 +78,9 @@ describe('Lighthouse chrome popup', function() {
8178
});
8279

8380
await page.goto('file://' + path.join(lighthouseExtensionPath, 'popup.html'), {waitUntil: 'networkidle2'});
84-
});
81+
}, 90 * 1000);
8582

86-
after(async () => {
83+
afterAll(async () => {
8784
if (browser) {
8885
await browser.close();
8986
}

clients/test/lightrider-entry-test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
'use strict';
77

88
const assert = require('assert');
9-
const jest = require('jest-mock');
109
const lhBackground = require('../lightrider-entry.js');
1110
const Runner = require('../../lighthouse-core/runner.js');
1211
const LHError = require('../../lighthouse-core/lib/lh-error.js');
1312

14-
/* eslint-env mocha */
13+
/* eslint-env jest */
1514

1615
describe('lightrider-entry', () => {
1716
describe('#runLighthouseInLR', () => {

jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ module.exports = {
1919
testMatch: [
2020
'**/lighthouse-core/**/*-test.js',
2121
'**/lighthouse-cli/**/*-test.js',
22+
'**/lighthouse-viewer/**/*-test.js',
23+
'**/lighthouse-viewer/**/*-test-pptr.js',
24+
'**/clients/test/**/*-test.js',
2225
],
2326
};

lighthouse-core/test/config/config-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ describe('Config', () => {
186186
it('loads an audit from node_modules/', () => {
187187
return assert.throws(_ => new Config({
188188
// Use a lighthouse dep as a stand in for a module.
189-
audits: ['mocha'],
189+
audits: ['lighthouse-logger'],
190190
}), function(err) {
191191
// Should throw an audit validation error, but *not* an audit not found error.
192192
return !/locate audit/.test(err) && /audit\(\) method/.test(err);
@@ -1046,7 +1046,7 @@ describe('Config', () => {
10461046

10471047
it('loads a gatherer from node_modules/', () => {
10481048
// Use a lighthouse dep as a stand in for a module.
1049-
assert.throws(_ => loadGatherer('mocha'), function(err) {
1049+
assert.throws(_ => loadGatherer('lighthouse-logger'), function(err) {
10501050
// Should throw a gatherer validation error, but *not* a gatherer not found error.
10511051
return !/locate gatherer/.test(err) && /beforePass\(\) method/.test(err);
10521052
});

lighthouse-viewer/test/viewer-test-pptr.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
'use strict';
77

8-
/* eslint-env mocha */
8+
/* eslint-env jest */
99

1010
const path = require('path');
1111
const assert = require('assert');
@@ -49,7 +49,7 @@ describe('Lighthouse Viewer', function() {
4949
});
5050
}
5151

52-
before(async function() {
52+
beforeAll(async function() {
5353
server.listen(portNumber, 'localhost');
5454

5555
// start puppeteer
@@ -65,7 +65,7 @@ describe('Lighthouse Viewer', function() {
6565
await viewerPage.waitForSelector('.lh-container', {timeout: 30000});
6666
});
6767

68-
after(async function() {
68+
afterAll(async function() {
6969
// Log any page load errors encountered in case before() failed.
7070
// eslint-disable-next-line no-console
7171
console.error(pageErrors);

package.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
"debug": "node --inspect-brk ./lighthouse-cli/index.js",
2525
"start": "node ./lighthouse-cli/index.js",
2626
"test": "yarn diff:sample-json && yarn lint --quiet && yarn unit && yarn type-check",
27-
"test-clients": "mocha \"clients/test/**/*-test.js\"",
28-
"test-viewer": "yarn unit-viewer && mocha lighthouse-viewer/test/viewer-test-pptr.js",
27+
"test-clients": "jest \"clients/\"",
28+
"test-viewer": "yarn unit-viewer && jest lighthouse-viewer/test/viewer-test-pptr.js",
2929
"test-lantern": "bash lighthouse-core/scripts/test-lantern.sh",
3030
"unit-core": "jest \"lighthouse-core/\"",
3131
"unit-core:ci": "jest --runInBand --coverage --ci \"lighthouse-core/\"",
3232
"unit-cli": "jest --runInBand \"lighthouse-cli/\"",
3333
"unit-cli:ci": "jest --runInBand --coverage --ci \"lighthouse-cli/\"",
34-
"unit-viewer": "mocha --reporter dot \"lighthouse-viewer/test/**/*-test.js\"",
34+
"unit-viewer": "jest \"lighthouse-viewer/\"",
3535
"unit": "yarn unit-core && yarn unit-cli && yarn unit-viewer",
3636
"unit:ci": "yarn unit-core:ci && yarn unit-cli:ci && yarn unit-viewer",
3737
"core-unit": "yarn unit-core",
@@ -50,7 +50,6 @@
5050
"fast": "yarn start --disable-device-emulation --throttlingMethod=provided",
5151
"deploy-viewer": "yarn build-viewer --deploy",
5252
"bundlesize": "bundlesize",
53-
"plots-smoke": "bash plots/test/smoke.sh",
5453
"timing-trace": "node lighthouse-core/scripts/generate-timing-trace.js",
5554
"changelog": "conventional-changelog --config ./build/changelog-generator/index.js --infile changelog.md --same-file",
5655
"type-check": "tsc -p . && tsc -p lighthouse-viewer/",
@@ -111,14 +110,14 @@
111110
"devtools-protocol": "0.0.588129",
112111
"eslint": "^4.19.1",
113112
"eslint-config-google": "^0.9.1",
113+
"esprima": "^4.0.1",
114114
"gh-pages": "^2.0.1",
115115
"glob": "^7.1.3",
116116
"idb-keyval": "2.2.0",
117117
"intl": "^1.2.5",
118118
"jest": "^24.3.0",
119119
"jsdom": "^12.2.0",
120120
"make-dir": "^1.3.0",
121-
"mocha": "^3.2.0",
122121
"npm-run-posix-or-windows": "^2.0.2",
123122
"nyc": "^11.6.0",
124123
"package-json-versionify": "^1.0.4",
@@ -138,12 +137,10 @@
138137
"configstore": "^3.1.1",
139138
"cssstyle": "1.2.1",
140139
"details-element-polyfill": "2.2.0",
141-
"esprima": "^4.0.1",
142140
"http-link-header": "^0.8.0",
143141
"inquirer": "^3.3.0",
144142
"intl-messageformat": "^2.2.0",
145143
"intl-messageformat-parser": "^1.4.0",
146-
"jest-mock": "^24.3.0",
147144
"jpeg-js": "0.1.2",
148145
"js-library-detector": "^5.1.0",
149146
"lighthouse-logger": "^1.2.0",

0 commit comments

Comments
 (0)