-
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(smokehouse): fail on finalUrl/errorCode mismatches #7227
Changes from 4 commits
50f7a9c
c377eb0
97ab34d
255bfbc
72b2219
ab4eb40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ const PAGE_HUNG_EXIT_CODE = 68; | |
const INSECURE_DOCUMENT_REQUEST_EXIT_CODE = 69; | ||
const RETRIES = 3; | ||
const NUMERICAL_EXPECTATION_REGEXP = /^(<=?|>=?)((\d|\.)+)$/; | ||
const VERBOSE = Boolean(process.env.LH_SMOKE_VERBOSE); | ||
|
||
/** | ||
* Attempt to resolve a path locally. If this fails, attempts to locate the path | ||
|
@@ -62,7 +63,7 @@ function resolveLocalOrCwd(payloadPath) { | |
* @return {ExpectedLHR} | ||
*/ | ||
function runLighthouse(url, configPath, isDebug) { | ||
isDebug = isDebug || Boolean(process.env.SMOKEHOUSE_DEBUG); | ||
isDebug = isDebug || Boolean(process.env.LH_SMOKE_DEBUG); | ||
|
||
const command = 'node'; | ||
const outputPath = `smokehouse-${Math.round(Math.random() * 100000)}.report.json`; | ||
|
@@ -276,8 +277,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') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super nit but mind flipping the order of these to There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]';
}; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
what year is it? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
@@ -311,16 +316,17 @@ 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 => { | ||
if (auditAssertion.equal) { | ||
correctCount++; | ||
} else { | ||
failedCount++; | ||
} | ||
|
||
if (!auditAssertion.equal || VERBOSE) { | ||
reportAssertion(auditAssertion); | ||
} | ||
}); | ||
|
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.
doesn't debug also save the LHR? Up to y'all if you want that :)
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.
nah. just writing to disk is good enough for me. verbose shouldn't be too verbose