Skip to content

Commit

Permalink
tests: finish removing mocha (#7429)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny committed Mar 9, 2019
1 parent a3b9cf3 commit e27ab6a
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 166 deletions.
11 changes: 4 additions & 7 deletions clients/test/extension/extension-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

/* eslint-env mocha */
/* eslint-env jest */

const path = require('path');
const assert = require('assert');
Expand Down Expand Up @@ -49,10 +49,7 @@ describe('Lighthouse chrome extension', function() {
});
}

before(async function() {
// eslint-disable-next-line
this.timeout(90 * 1000);

beforeAll(async function() {
// read original manifest
originalManifest = fs.readFileSync(manifestLocation);

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

after(async () => {
afterAll(async () => {
// put the default manifest back
fs.writeFileSync(manifestLocation, originalManifest);

Expand Down
11 changes: 4 additions & 7 deletions clients/test/extension/popup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

/* eslint-env mocha */
/* eslint-env jest */

const path = require('path');
const assert = require('assert');
Expand Down Expand Up @@ -36,10 +36,7 @@ describe('Lighthouse chrome popup', function() {
let page;
const pageErrors = [];

before(async function() {
// eslint-disable-next-line
this.timeout(90 * 1000);

beforeAll(async function() {
// start puppeteer
browser = await puppeteer.launch({
headless: false,
Expand Down Expand Up @@ -81,9 +78,9 @@ describe('Lighthouse chrome popup', function() {
});

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

after(async () => {
afterAll(async () => {
if (browser) {
await browser.close();
}
Expand Down
3 changes: 1 addition & 2 deletions clients/test/lightrider-entry-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
'use strict';

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

/* eslint-env mocha */
/* eslint-env jest */

describe('lightrider-entry', () => {
describe('#runLighthouseInLR', () => {
Expand Down
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ module.exports = {
testMatch: [
'**/lighthouse-core/**/*-test.js',
'**/lighthouse-cli/**/*-test.js',
'**/lighthouse-viewer/**/*-test.js',
'**/lighthouse-viewer/**/*-test-pptr.js',
'**/clients/test/**/*-test.js',
],
};
4 changes: 2 additions & 2 deletions lighthouse-core/test/config/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('Config', () => {
it('loads an audit from node_modules/', () => {
return assert.throws(_ => new Config({
// Use a lighthouse dep as a stand in for a module.
audits: ['mocha'],
audits: ['lighthouse-logger'],
}), function(err) {
// Should throw an audit validation error, but *not* an audit not found error.
return !/locate audit/.test(err) && /audit\(\) method/.test(err);
Expand Down Expand Up @@ -1046,7 +1046,7 @@ describe('Config', () => {

it('loads a gatherer from node_modules/', () => {
// Use a lighthouse dep as a stand in for a module.
assert.throws(_ => loadGatherer('mocha'), function(err) {
assert.throws(_ => loadGatherer('lighthouse-logger'), function(err) {
// Should throw a gatherer validation error, but *not* a gatherer not found error.
return !/locate gatherer/.test(err) && /beforePass\(\) method/.test(err);
});
Expand Down
6 changes: 3 additions & 3 deletions lighthouse-viewer/test/viewer-test-pptr.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

/* eslint-env mocha */
/* eslint-env jest */

const path = require('path');
const assert = require('assert');
Expand Down Expand Up @@ -49,7 +49,7 @@ describe('Lighthouse Viewer', function() {
});
}

before(async function() {
beforeAll(async function() {
server.listen(portNumber, 'localhost');

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

after(async function() {
afterAll(async function() {
// Log any page load errors encountered in case before() failed.
// eslint-disable-next-line no-console
console.error(pageErrors);
Expand Down
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
"debug": "node --inspect-brk ./lighthouse-cli/index.js",
"start": "node ./lighthouse-cli/index.js",
"test": "yarn diff:sample-json && yarn lint --quiet && yarn unit && yarn type-check",
"test-clients": "mocha \"clients/test/**/*-test.js\"",
"test-viewer": "yarn unit-viewer && mocha lighthouse-viewer/test/viewer-test-pptr.js",
"test-clients": "jest \"clients/\"",
"test-viewer": "yarn unit-viewer && jest lighthouse-viewer/test/viewer-test-pptr.js",
"test-lantern": "bash lighthouse-core/scripts/test-lantern.sh",
"unit-core": "jest \"lighthouse-core/\"",
"unit-core:ci": "jest --runInBand --coverage --ci \"lighthouse-core/\"",
"unit-cli": "jest --runInBand \"lighthouse-cli/\"",
"unit-cli:ci": "jest --runInBand --coverage --ci \"lighthouse-cli/\"",
"unit-viewer": "mocha --reporter dot \"lighthouse-viewer/test/**/*-test.js\"",
"unit-viewer": "jest \"lighthouse-viewer/\"",
"unit": "yarn unit-core && yarn unit-cli && yarn unit-viewer",
"unit:ci": "yarn unit-core:ci && yarn unit-cli:ci && yarn unit-viewer",
"core-unit": "yarn unit-core",
Expand All @@ -50,7 +50,6 @@
"fast": "yarn start --disable-device-emulation --throttlingMethod=provided",
"deploy-viewer": "yarn build-viewer --deploy",
"bundlesize": "bundlesize",
"plots-smoke": "bash plots/test/smoke.sh",
"timing-trace": "node lighthouse-core/scripts/generate-timing-trace.js",
"changelog": "conventional-changelog --config ./build/changelog-generator/index.js --infile changelog.md --same-file",
"type-check": "tsc -p . && tsc -p lighthouse-viewer/",
Expand Down Expand Up @@ -111,14 +110,14 @@
"devtools-protocol": "0.0.588129",
"eslint": "^4.19.1",
"eslint-config-google": "^0.9.1",
"esprima": "^4.0.1",
"gh-pages": "^2.0.1",
"glob": "^7.1.3",
"idb-keyval": "2.2.0",
"intl": "^1.2.5",
"jest": "^24.3.0",
"jsdom": "^12.2.0",
"make-dir": "^1.3.0",
"mocha": "^3.2.0",
"npm-run-posix-or-windows": "^2.0.2",
"nyc": "^11.6.0",
"package-json-versionify": "^1.0.4",
Expand All @@ -138,12 +137,10 @@
"configstore": "^3.1.1",
"cssstyle": "1.2.1",
"details-element-polyfill": "2.2.0",
"esprima": "^4.0.1",
"http-link-header": "^0.8.0",
"inquirer": "^3.3.0",
"intl-messageformat": "^2.2.0",
"intl-messageformat-parser": "^1.4.0",
"jest-mock": "^24.3.0",
"jpeg-js": "0.1.2",
"js-library-detector": "^5.1.0",
"lighthouse-logger": "^1.2.0",
Expand Down

0 comments on commit e27ab6a

Please sign in to comment.