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(smoke): assert errorCode in expectations #6851

Merged
merged 1 commit into from
Dec 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lighthouse-cli/test/smokehouse/smokehouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ function findDifference(path, actual, expected) {

/**
* Collate results into comparisons of actual and expected scores on each audit.
* @param {{finalUrl: string, audits: !Array}} actual
* @param {{finalUrl: string, audits: !Array}} expected
* @param {{finalUrl: string, audits: !Array, errorCode: string}} actual
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* @param {{finalUrl: string, audits: !Array, errorCode: string}} actual
* @param {{finalUrl: string, audits: Array, errorCode?: string}} actual

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think these files are actually type checked though, audits isn't an Array...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hah, it certainly isn't. Opened #6852.

* @param {{finalUrl: string, audits: !Array, errorCode: string}} expected
* @return {{finalUrl: !Object, audits: !Array<!Object>}}
*/
function collateResults(actual, expected) {
Expand Down Expand Up @@ -231,6 +231,12 @@ function collateResults(actual, expected) {
equal: actual.finalUrl === expected.finalUrl,
},
audits: collatedAudits,
errorCode: {
category: 'error code',
actual: actual.errorCode,
expected: expected.errorCode,
equal: actual.errorCode === expected.errorCode,
},
};
}

Expand Down Expand Up @@ -274,11 +280,12 @@ function reportAssertion(assertion) {
/**
* Log all the comparisons between actual and expected test results, then print
* summary. Returns count of passed and failed tests.
* @param {{finalUrl: !Object, audits: !Array<!Object>}} results
* @param {{finalUrl: !Object, audits: !Array<!Object>, errorCode: !Object}} results
Copy link
Collaborator

Choose a reason for hiding this comment

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

FWIW, we don't need all these ! anymore, so it'd be cool to be cleaning them up as we go if we can, but I don't think any of the comments are real atm

* @return {{passed: number, failed: number}}
*/
function report(results) {
reportAssertion(results.finalUrl);
reportAssertion(results.errorCode);

let correctCount = 0;
let failedCount = 0;
Expand Down