-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
core(audit-mode): do not require a URL #5495
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 |
---|---|---|
|
@@ -72,7 +72,7 @@ describe('Runner', () => { | |
|
||
// uses the files on disk from the -G test. ;) | ||
it('-A audits from saved artifacts and doesn\'t gather', () => { | ||
const opts = {url, config: generateConfig({auditMode: artifactsPath}), driverMock}; | ||
const opts = {config: generateConfig({auditMode: artifactsPath}), driverMock}; | ||
return Runner.run(null, opts).then(_ => { | ||
assert.equal(loadArtifactsSpy.called, true, 'loadArtifacts was not called'); | ||
assert.equal(gatherRunnerRunSpy.called, false, 'GatherRunner.run was called'); | ||
|
@@ -83,7 +83,7 @@ describe('Runner', () => { | |
|
||
it('-A throws if the settings change', async () => { | ||
const settings = {auditMode: artifactsPath, disableDeviceEmulation: true}; | ||
const opts = {url, config: generateConfig(settings), driverMock}; | ||
const opts = {config: generateConfig(settings), driverMock}; | ||
try { | ||
await Runner.run(null, opts); | ||
assert.fail('should have thrown'); | ||
|
@@ -92,6 +92,17 @@ describe('Runner', () => { | |
} | ||
}); | ||
|
||
it('-A throws if the URL changes', async () => { | ||
const settings = {auditMode: artifactsPath, disableDeviceEmulation: true}; | ||
const opts = {url: 'https://example.com', config: generateConfig(settings), driverMock}; | ||
try { | ||
await Runner.run(null, opts); | ||
assert.fail('should have thrown'); | ||
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. won't this be caught by the try/catch and so never fail? 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. yeah but the message won't match, it's the same weird pattern observed elsewhere in the tests :) jest has some much niftier matchers FWIW ;) 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. oh right. That's confusing but ok :) |
||
} catch (err) { | ||
assert.ok(/different URL/.test(err.message), 'should have prevented run'); | ||
} | ||
}); | ||
|
||
it('-GA is a normal run but it saves artifacts to disk', () => { | ||
const settings = {auditMode: artifactsPath, gatherMode: artifactsPath}; | ||
const opts = {url, config: generateConfig(settings), driverMock}; | ||
|
@@ -187,8 +198,6 @@ describe('Runner', () => { | |
}); | ||
|
||
it('accepts trace artifacts as paths and outputs appropriate data', () => { | ||
const url = 'https://example.com/'; | ||
|
||
const config = new Config({ | ||
settings: { | ||
auditMode: __dirname + '/fixtures/artifacts/perflog/', | ||
|
@@ -198,7 +207,7 @@ describe('Runner', () => { | |
], | ||
}); | ||
|
||
return Runner.run({}, {url, config}).then(results => { | ||
return Runner.run({}, {config}).then(results => { | ||
const audits = results.lhr.audits; | ||
assert.equal(audits['user-timings'].displayValue[1], 2); | ||
assert.equal(audits['user-timings'].rawValue, false); | ||
|
@@ -233,7 +242,6 @@ describe('Runner', () => { | |
|
||
describe('Bad required artifact handling', () => { | ||
it('outputs an error audit result when trace required but not provided', () => { | ||
const url = 'https://example.com'; | ||
const config = new Config({ | ||
settings: { | ||
auditMode: __dirname + '/fixtures/artifacts/empty-artifacts/', | ||
|
@@ -244,7 +252,7 @@ describe('Runner', () => { | |
], | ||
}); | ||
|
||
return Runner.run({}, {url, config}).then(results => { | ||
return Runner.run({}, {config}).then(results => { | ||
const auditResult = results.lhr.audits['user-timings']; | ||
assert.strictEqual(auditResult.rawValue, null); | ||
assert.strictEqual(auditResult.scoreDisplayMode, 'error'); | ||
|
@@ -253,7 +261,6 @@ describe('Runner', () => { | |
}); | ||
|
||
it('outputs an error audit result when missing a required artifact', () => { | ||
const url = 'https://example.com'; | ||
const config = new Config({ | ||
settings: { | ||
auditMode: __dirname + '/fixtures/artifacts/empty-artifacts/', | ||
|
@@ -264,7 +271,7 @@ describe('Runner', () => { | |
], | ||
}); | ||
|
||
return Runner.run({}, {url, config}).then(results => { | ||
return Runner.run({}, {config}).then(results => { | ||
const auditResult = results.lhr.audits['content-width']; | ||
assert.strictEqual(auditResult.rawValue, null); | ||
assert.strictEqual(auditResult.scoreDisplayMode, 'error'); | ||
|
@@ -312,7 +319,6 @@ describe('Runner', () => { | |
|
||
it('produces an error audit result when an audit throws a non-fatal Error', () => { | ||
const errorMessage = 'Audit yourself'; | ||
const url = 'https://example.com'; | ||
const config = new Config({ | ||
settings: { | ||
auditMode: __dirname + '/fixtures/artifacts/empty-artifacts/', | ||
|
@@ -329,7 +335,7 @@ describe('Runner', () => { | |
], | ||
}); | ||
|
||
return Runner.run({}, {url, config}).then(results => { | ||
return Runner.run({}, {config}).then(results => { | ||
const auditResult = results.lhr.audits['throwy-audit']; | ||
assert.strictEqual(auditResult.rawValue, null); | ||
assert.strictEqual(auditResult.scoreDisplayMode, 'error'); | ||
|
@@ -339,7 +345,6 @@ describe('Runner', () => { | |
|
||
it('rejects if an audit throws a fatal error', () => { | ||
const errorMessage = 'Uh oh'; | ||
const url = 'https://example.com'; | ||
const config = new Config({ | ||
settings: { | ||
auditMode: __dirname + '/fixtures/artifacts/empty-artifacts/', | ||
|
@@ -358,14 +363,13 @@ describe('Runner', () => { | |
], | ||
}); | ||
|
||
return Runner.run({}, {url, config}).then( | ||
return Runner.run({}, {config}).then( | ||
_ => assert.ok(false), | ||
err => assert.strictEqual(err.message, errorMessage)); | ||
}); | ||
}); | ||
|
||
it('accepts devtoolsLog in artifacts', () => { | ||
const url = 'https://example.com'; | ||
const config = new Config({ | ||
settings: { | ||
auditMode: __dirname + '/fixtures/artifacts/perflog/', | ||
|
@@ -375,7 +379,7 @@ describe('Runner', () => { | |
], | ||
}); | ||
|
||
return Runner.run({}, {url, config}).then(results => { | ||
return Runner.run({}, {config}).then(results => { | ||
const audits = results.lhr.audits; | ||
assert.equal(audits['critical-request-chains'].displayValue, '5 chains found'); | ||
assert.equal(audits['critical-request-chains'].rawValue, false); | ||
|
@@ -487,7 +491,6 @@ describe('Runner', () => { | |
}); | ||
|
||
it('results include artifacts when given artifacts and audits', () => { | ||
const url = 'https://example.com'; | ||
const config = new Config({ | ||
settings: { | ||
auditMode: __dirname + '/fixtures/artifacts/perflog/', | ||
|
@@ -497,7 +500,7 @@ describe('Runner', () => { | |
], | ||
}); | ||
|
||
return Runner.run({}, {url, config}).then(results => { | ||
return Runner.run({}, {config}).then(results => { | ||
assert.strictEqual(results.artifacts.ViewportDimensions.innerWidth, 412); | ||
assert.strictEqual(results.artifacts.ViewportDimensions.innerHeight, 732); | ||
}); | ||
|
@@ -528,15 +531,14 @@ describe('Runner', () => { | |
}); | ||
|
||
it('includes any LighthouseRunWarnings from artifacts in output', () => { | ||
const url = 'https://example.com'; | ||
const config = new Config({ | ||
settings: { | ||
auditMode: __dirname + '/fixtures/artifacts/perflog/', | ||
}, | ||
audits: [], | ||
}); | ||
|
||
return Runner.run(null, {url, config, driverMock}).then(results => { | ||
return Runner.run(null, {config, driverMock}).then(results => { | ||
assert.deepStrictEqual(results.lhr.runWarnings, [ | ||
'I\'m a warning!', | ||
'Also a warning', | ||
|
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.
might throw a wrench in the type checking works, but
opts.url
should now be optional in the function params?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.
done