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(smokehouse): check runWarnings #9732

Merged
merged 3 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lighthouse-cli/test/smokehouse/error-expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = [
requestedUrl: 'http://localhost:10200/infinite-loop.html',
finalUrl: 'http://localhost:10200/infinite-loop.html',
runtimeError: {code: 'PAGE_HUNG'},
runWarnings: ['Lighthouse was unable to reliably load the URL you requested because the page stopped responding.'],
audits: {
'first-contentful-paint': {
scoreDisplayMode: 'error',
Expand All @@ -42,6 +43,7 @@ module.exports = [
requestedUrl: 'https://expired.badssl.com',
finalUrl: 'https://expired.badssl.com/',
runtimeError: {code: 'INSECURE_DOCUMENT_REQUEST'},
runWarnings: ['The URL you have provided does not have a valid security certificate. net::ERR_CERT_DATE_INVALID'],
audits: {
'first-contentful-paint': {
scoreDisplayMode: 'error',
Expand Down
1 change: 1 addition & 0 deletions lighthouse-cli/test/smokehouse/seo/expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ module.exports = [
code: 'ERRORED_DOCUMENT_REQUEST',
message: /Status code: 403/,
},
runWarnings: ['Lighthouse was unable to reliably load the page you requested. Make sure you are testing the correct URL and that the server is properly responding to all requests. (Status code: 403)'],
audits: {
'http-status-code': {
score: null,
Expand Down
5 changes: 5 additions & 0 deletions lighthouse-cli/test/smokehouse/smokehouse-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ function collateResults(actual, expected) {
const runtimeErrorAssertion = makeComparison('runtimeError', actual.lhr.runtimeError,
expected.lhr.runtimeError);

// Same for warnings.
const runWarningsAssertion = makeComparison('runWarnings', actual.lhr.runWarnings,
expected.lhr.runWarnings || []);

/** @type {Smokehouse.Comparison[]} */
let artifactAssertions = [];
if (expected.artifacts) {
Expand Down Expand Up @@ -179,6 +183,7 @@ function collateResults(actual, expected) {
equal: actual.lhr.finalUrl === expected.lhr.finalUrl,
},
runtimeErrorAssertion,
runWarningsAssertion,
...artifactAssertions,
...auditAssertions,
];
Expand Down
2 changes: 1 addition & 1 deletion types/smokehouse.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
diff?: Difference | null;
}

export type ExpectedLHR = Pick<LH.Result, 'audits' | 'finalUrl' | 'requestedUrl' | 'runtimeError'>
export type ExpectedLHR = Pick<LH.Result, 'audits' | 'finalUrl' | 'requestedUrl' | 'runWarnings' | 'runtimeError'>

export type ExpectedRunnerResult = {
lhr: ExpectedLHR,
Expand Down