-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests(runner): drop usages of legacy runner #15047
Conversation
Previously the new runner was being given a gatherFn that just ran the legacy runner to do the collection (which we mocked the hell out of to get what we want). This PR stops using legacy runner to fill out the gatherFn and instead uses various bits of the navigation runner implementation. Also, legacy config stuff is replaced with calls to Is that everything? |
}); | ||
}); | ||
|
||
it('rejects when given neither passes nor artifacts', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general purpose runner is not responsible for checking this, the error is specific to _gatherArtifactsFromBrowser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What checks the equivalent now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
navigation-runner.js
(sort of)
It rejects when there are no "config navigations" but there should always be 1 even if the artifacts
array on the config doesn't exist or is empty.
lighthouse/core/test/gather/navigation-runner-test.js
Lines 193 to 196 in 3ba11a8
it('should throw if no navigations available', async () => { | |
resolvedConfig = {...resolvedConfig, navigations: null}; | |
await expect(run()).rejects.toBeTruthy(); | |
}); |
const audits = results.lhr.audits; | ||
assert.equal(audits['user-timings'].displayValue, '2 user timings'); | ||
assert.deepStrictEqual(audits['user-timings'].details.items.map(i => i.startTime), | ||
[0.002, 1000.954]); | ||
}); | ||
}); | ||
|
||
it('rejects when given an invalid trace artifact', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trace artifact is not given special treatment by the FR runner anymore
@@ -838,55 +890,19 @@ describe('Runner', () => { | |||
expect(lhr.runtimeError.code).toEqual(NO_FCP.code); | |||
expect(lhr.runtimeError.message).toMatch(/did not paint any content.*\(NO_FCP\)/); | |||
}); | |||
|
|||
it('includes a pageLoadError runtimeError over any gatherer runtimeErrors', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general purpose runner is not responsible for this logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
navigation-runner.js
lighthouse/core/test/gather/navigation-runner-test.js
Lines 447 to 462 in 3ba11a8
it('returns navigate errors', async () => { | |
const {navigation} = createNavigation(); | |
const noFcp = new LighthouseError(LighthouseError.errors.NO_FCP); | |
mocks.navigationMock.gotoURL.mockImplementation( | |
/** @param {*} context @param {string} url */ | |
(context, url) => { | |
if (url.includes('blank')) return {finalDisplayedUrl: 'about:blank', warnings: []}; | |
throw noFcp; | |
} | |
); | |
const {artifacts, pageLoadError} = await run(navigation); | |
expect(pageLoadError).toBe(noFcp); | |
expect(artifacts).toEqual({}); | |
}); |
Yes + removing some obsolete tests |
}); | ||
}); | ||
|
||
it('rejects when given neither passes nor artifacts', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What checks the equivalent now?
settings: { | ||
auditMode: moduleDir + '/fixtures/artifacts/perflog/', | ||
}, | ||
audits: [ | ||
'user-timings', | ||
], | ||
artifacts: [ | ||
{id: 'Trace', gatherer: 'trace'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are artifacts
not optional if you're loading via auditMode
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are optional, but initializeConfig
filters out any audits because all required artifacts are missing.
@@ -838,55 +890,19 @@ describe('Runner', () => { | |||
expect(lhr.runtimeError.code).toEqual(NO_FCP.code); | |||
expect(lhr.runtimeError.message).toMatch(/did not paint any content.*\(NO_FCP\)/); | |||
}); | |||
|
|||
it('includes a pageLoadError runtimeError over any gatherer runtimeErrors', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is now?
Runner._gatherArtifactsFromBrowser
ingatherFn
LegacyResolvedConfig.fromJson
calls to newinitializeConfig