diff --git a/core/gather/navigation-runner.js b/core/gather/navigation-runner.js index 33fef1f139c8..dcd79e97b208 100644 --- a/core/gather/navigation-runner.js +++ b/core/gather/navigation-runner.js @@ -92,7 +92,9 @@ async function _navigate(navigationContext) { return {requestedUrl, mainDocumentUrl, navigationError: undefined}; } catch (err) { if (!(err instanceof LighthouseError)) throw err; - if (err.code !== 'NO_FCP' && err.code !== 'PAGE_HUNG' && err.code !== 'TARGET_CRASHED') throw err; + if (err.code !== 'NO_FCP' && err.code !== 'PAGE_HUNG' && err.code !== 'TARGET_CRASHED') { + throw err; + } if (typeof requestor !== 'string') throw err; // TODO: Make the urls optional here so we don't need to throw an error with a callback requestor. diff --git a/core/test/gather/mock-driver.js b/core/test/gather/mock-driver.js index d3f88dbfaf8a..840461bcd232 100644 --- a/core/test/gather/mock-driver.js +++ b/core/test/gather/mock-driver.js @@ -157,8 +157,9 @@ function createMockDriver() { const context = createMockExecutionContext(); const targetManager = createMockTargetManager(session); - // our `fatalRejection` - let rej; + // The `fatalRejection` + /** @param {any} _ */ + let rej = _ => {}; const promise = new Promise((_, theRej) => { rej = theRej; }); @@ -177,8 +178,8 @@ function createMockDriver() { fetchResource: fnAny(), }, networkMonitor: new NetworkMonitor(targetManager.asTargetManager()), - listenForCrashes: session.on('Inspector.targetCrashed', _ => { - rej(new Error('TARGETCRAHSZHZD')); + listenForCrashes: session.on('Inspector.targetCrashed', () => { + rej(new Error('TARGET_CRASHED')); }), fatalRejection: {promise, rej}, diff --git a/core/test/gather/session-test.js b/core/test/gather/session-test.js index a0c63c68686b..b69818917ce8 100644 --- a/core/test/gather/session-test.js +++ b/core/test/gather/session-test.js @@ -104,6 +104,7 @@ describe('ProtocolSession', () => { describe('.dispose', () => { it('should detach from the session', async () => { const detach = fnAny(); + detach.mockResolvedValue(undefined); class MockCdpSession extends EventEmitter { constructor() { super();