-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
sort trace by timestamp before calculating FMP #756
Changes from all commits
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 |
---|---|---|
|
@@ -15,34 +15,59 @@ | |
*/ | ||
'use strict'; | ||
|
||
const Audit = require('../../audits/first-meaningful-paint.js'); | ||
const FMPAudit = require('../../audits/first-meaningful-paint.js'); | ||
const Audit = require('../../audits/audit.js'); | ||
const assert = require('assert'); | ||
const traceEvents = require('../fixtures/traces/progressive-app.json'); | ||
const badNavStartTrace = require('../fixtures/traces/bad-nav-start-ts.json'); | ||
|
||
/* eslint-env mocha */ | ||
describe('Performance: first-meaningful-paint audit', () => { | ||
it('scores a -1 when no trace data is present', () => { | ||
return Audit.audit({}).then(response => { | ||
return assert.equal(response.score, -1); | ||
return FMPAudit.audit({}).then(result => { | ||
assert.equal(result.score, -1); | ||
assert.ok(result.debugString); | ||
}); | ||
}); | ||
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. this test was not actually testing faulty trace data after the trace artifact format change :) 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. Newer tests are more robust. Looking good. 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. and my earlier comment is caught by the tests you've written. Gotcha. |
||
|
||
it('scores a -1 when faulty trace data is present', () => { | ||
return Audit.audit({boo: 'ya'}).then(response => { | ||
return assert.equal(response.score, -1); | ||
const artifacts = { | ||
traces: { | ||
[Audit.DEFAULT_PASS]: {boo: 'ya'} | ||
} | ||
}; | ||
return FMPAudit.audit(artifacts).then(result => { | ||
assert.equal(result.rawValue, -1); | ||
assert.ok(result.debugString); | ||
}); | ||
}); | ||
|
||
it('scores a -1 and returns an error when navigation start is before trace start', () => { | ||
const artifacts = { | ||
traces: { | ||
[Audit.DEFAULT_PASS]: badNavStartTrace | ||
} | ||
}; | ||
return FMPAudit.audit(artifacts).then(result => { | ||
assert.equal(result.rawValue, -1); | ||
assert.ok(/navigationStart/.test(result.debugString)); | ||
}); | ||
}); | ||
|
||
describe('measures the pwa.rocks example correctly', () => { | ||
let fmpResult; | ||
|
||
it('processes a valid trace file', done => { | ||
assert.doesNotThrow(_ => { | ||
Audit.audit({traces: {[Audit.DEFAULT_PASS]: {traceEvents}}}) | ||
.then(response => { | ||
fmpResult = response; | ||
done(); | ||
}); | ||
it('processes a valid trace file', () => { | ||
const artifacts = { | ||
traces: { | ||
[Audit.DEFAULT_PASS]: {traceEvents} | ||
} | ||
}; | ||
|
||
return FMPAudit.audit(artifacts).then(result => { | ||
fmpResult = result; | ||
}).catch(_ => { | ||
assert.ok(false); | ||
}); | ||
}); | ||
|
||
|
Large diffs are not rendered by default.
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.
I'm trying to reason what this throw will mean for the reporter output. Talking in person, it looks like it should still result in a -1 debug string.