Skip to content

Commit

Permalink
Add first stab at test
Browse files Browse the repository at this point in the history
  • Loading branch information
tkindy committed Feb 26, 2021
1 parent 1b9c4e1 commit d4fb067
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
15 changes: 15 additions & 0 deletions lighthouse-cli/test/cli/run-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,18 @@ describe('Parsing --chrome-flags', () => {
);
});
});

it('doesn\'t launch a local Chrome when given an external hostname', async () => {
const launch = require('chrome-launcher').launch;
jest.doMock('chrome-launcher', () => ({
launch: jest.fn(() => Promise.reject()),
}));

/** @type {!jest.MockedFunction<typeof launch>} */
const mockLaunch = (launch);

const url = 'chrome://version';
await run.runLighthouse(url, getFlags(`${url} --hostname=192.168.1.1`), fastConfig);

expect(mockLaunch.mock).toBeCalledTimes(0);
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"@types/gh-pages": "^2.0.0",
"@types/google.analytics": "0.0.39",
"@types/inquirer": "^7.3.1",
"@types/jest": "^24.0.9",
"@types/jest": "^24.9.0",
"@types/jpeg-js": "^0.3.0",
"@types/lodash.clonedeep": "^4.5.6",
"@types/lodash.get": "^4.4.6",
Expand Down
17 changes: 6 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -586,17 +586,12 @@
"@types/istanbul-lib-coverage" "*"
"@types/istanbul-lib-report" "*"

"@types/jest-diff@*":
version "20.0.1"
resolved "https://registry.yarnpkg.com/@types/jest-diff/-/jest-diff-20.0.1.tgz#35cc15b9c4f30a18ef21852e255fdb02f6d59b89"
integrity sha512-yALhelO3i0hqZwhjtcr6dYyaLoCHbAMshwtj6cGxTvHZAKXHsYGdff6E8EPw3xLKY0ELUTQ69Q1rQiJENnccMA==

"@types/jest@^24.0.9":
version "24.0.9"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-24.0.9.tgz#74ce9cf337f25e189aa18f76ab3d65e8669b55f2"
integrity sha512-k3OOeevcBYLR5pdsOv5g3OP94h3mrJmLPHFEPWgbbVy2tGv0TZ/TlygiC848ogXhK8NL0I5up7YYtwpCp8xCJA==
"@types/jest@^24.9.0":
version "24.9.1"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-24.9.1.tgz#02baf9573c78f1b9974a5f36778b366aa77bd534"
integrity sha512-Fb38HkXSVA4L8fGKEZ6le5bB8r6MRWlOCZbVuWZcmOMSCd2wCYOwN1ibj8daIoV9naq7aaOZjrLCoCMptKU/4Q==
dependencies:
"@types/jest-diff" "*"
jest-diff "^24.3.0"

"@types/jpeg-js@^0.3.0":
version "0.3.0"
Expand Down Expand Up @@ -4464,7 +4459,7 @@ jest-config@^24.9.0:
pretty-format "^24.9.0"
realpath-native "^1.1.0"

jest-diff@^24.9.0:
jest-diff@^24.3.0, jest-diff@^24.9.0:
version "24.9.0"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-24.9.0.tgz#931b7d0d5778a1baf7452cb816e325e3724055da"
integrity sha512-qMfrTs8AdJE2iqrTp0hzh7kTd2PQWrsFyj9tORoKmu32xjPjeE4NyjVRDz8ybYwqS2ik8N4hsIpiVTyFeo2lBQ==
Expand Down

0 comments on commit d4fb067

Please sign in to comment.