From d4fb067ad07600e2bc8d907e78ac4d163f891078 Mon Sep 17 00:00:00 2001 From: Tyler Kindy Date: Fri, 26 Feb 2021 09:50:42 -0500 Subject: [PATCH] Add first stab at test --- lighthouse-cli/test/cli/run-test.js | 15 +++++++++++++++ package.json | 2 +- yarn.lock | 17 ++++++----------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/lighthouse-cli/test/cli/run-test.js b/lighthouse-cli/test/cli/run-test.js index 89e5acf4a77d..3c965eb5a1dc 100644 --- a/lighthouse-cli/test/cli/run-test.js +++ b/lighthouse-cli/test/cli/run-test.js @@ -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} */ + const mockLaunch = (launch); + + const url = 'chrome://version'; + await run.runLighthouse(url, getFlags(`${url} --hostname=192.168.1.1`), fastConfig); + + expect(mockLaunch.mock).toBeCalledTimes(0); +}); diff --git a/package.json b/package.json index b0dfcfc013d5..d43ff2e1721f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index 879991d1b8e9..54919d7c5b00 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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==