Skip to content
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

Merged
merged 7 commits into from
Jul 6, 2023
Merged

tests(runner): drop usages of legacy runner #15047

merged 7 commits into from
Jul 6, 2023

Conversation

adamraine
Copy link
Member

@adamraine adamraine commented May 5, 2023

  • Stop using Runner._gatherArtifactsFromBrowser in gatherFn
  • Convert LegacyResolvedConfig.fromJson calls to new initializeConfig
  • Remove some obsolete tests (I will call these out individually)

@adamraine adamraine requested a review from a team as a code owner May 5, 2023 00:23
@adamraine adamraine requested review from connorjclark and removed request for a team May 5, 2023 00:23
@connorjclark connorjclark changed the title tests: convert runner test to use FR tests: convert runner test to use new runner, drop legacy runner May 5, 2023
@connorjclark connorjclark changed the title tests: convert runner test to use new runner, drop legacy runner tests: convert runner test to use new runner instead of legacy runner May 5, 2023
@connorjclark
Copy link
Collaborator

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 initializeConfig.

Is that everything?

});
});

it('rejects when given neither passes nor artifacts', async () => {
Copy link
Member Author

@adamraine adamraine May 5, 2023

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

Copy link
Member

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?

Copy link
Member Author

@adamraine adamraine May 5, 2023

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.

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 () => {
Copy link
Member Author

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 () => {
Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is now?

Copy link
Member Author

@adamraine adamraine May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

navigation-runner.js

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({});
});

@adamraine
Copy link
Member Author

Is that everything?

Yes + removing some obsolete tests

});
});

it('rejects when given neither passes nor artifacts', async () => {
Copy link
Member

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'},
Copy link
Member

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?

Copy link
Member Author

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 () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is now?

@adamraine adamraine changed the title tests: convert runner test to use new runner instead of legacy runner tests(runner): convert to use new runner instead of legacy runner Jul 6, 2023
@adamraine adamraine changed the title tests(runner): convert to use new runner instead of legacy runner tests(runner): drop usages of legacy runner Jul 6, 2023
@adamraine adamraine merged commit c0efe60 into main Jul 6, 2023
31 checks passed
@adamraine adamraine deleted the gather-test-fr branch July 6, 2023 19:33
@Tonyadelgado1982

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants