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): fail on finalUrl/errorCode mismatches #7227

Merged
merged 6 commits into from
Feb 14, 2019
Merged
Changes from 2 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
16 changes: 9 additions & 7 deletions lighthouse-cli/test/smokehouse/smokehouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,12 @@ function reportAssertion(assertion) {
RegExp.prototype.toJSON = RegExp.prototype.toString;

if (assertion.equal) {
console.log(` ${log.greenify(log.tick)} ${assertion.category}: ` +
log.greenify(assertion.actual));
if (assertion.actual !== null && typeof assertion.actual === 'object') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

super nit but mind flipping the order of these to is an object && is not null? took me a bit to realize this was just an object check

Copy link
Member

Choose a reason for hiding this comment

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

can we just use a helper method like so?

const isPlainObject = function (obj) {
	return Object.prototype.toString.call(obj) === '[object Object]';
};

Copy link
Member

Choose a reason for hiding this comment

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

Object.prototype.toString.call(obj) === '[object Object]';

what year is it?

Copy link
Member

Choose a reason for hiding this comment

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

:P

console.log(` ${log.greenify(log.tick)} ${assertion.category}`);
} else {
console.log(` ${log.greenify(log.tick)} ${assertion.category}: ` +
log.greenify(assertion.actual));
}
} else {
if (assertion.diff) {
const diff = assertion.diff;
Expand Down Expand Up @@ -311,17 +315,15 @@ function reportAssertion(assertion) {
* @return {{passed: number, failed: number}}
*/
function report(results) {
reportAssertion(results.finalUrl);
reportAssertion(results.errorCode);

let correctCount = 0;
let failedCount = 0;
results.audits.forEach(auditAssertion => {

[results.finalUrl, results.errorCode, ...results.audits].forEach(auditAssertion => {
reportAssertion(auditAssertion);
if (auditAssertion.equal) {
correctCount++;
} else {
failedCount++;
reportAssertion(auditAssertion);
}
});

Expand Down