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

Update more gatherers to use gather error instead of -1 artifacts #1623

Merged
merged 8 commits into from
Feb 4, 2017

Conversation

brendankenny
Copy link
Member

@brendankenny brendankenny commented Feb 3, 2017

followup to #1560, continuing work on #941. This removes catches, etc from gatherers, letting any exceptions handle themselves as gatherer errors. Separated by commit for easier review, but most of these are fairly straightforward.

This leaves only the Manifest gatherer and the deobetterweb gatherers to go; thought I'd break here before it got too unwieldy.

@@ -32,7 +32,7 @@ class AxeAudit extends Audit {
* @return {!AuditResult}
*/
static audit(artifacts) {
const violations = artifacts.Accessibility.violations || [];
const violations = artifacts.Accessibility.violations;
Copy link
Member Author

Choose a reason for hiding this comment

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

now asserted as an array in the gatherer since axe says any valid result will include the violations array.

return Accessibility._errorAccessibility('Unable to parse axe results');
}

if (returnedValue.error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This appears to be from working around issues in the old evaluateAsync before @patrickhulce fixed up the error handling to properly reject. So, removed.


const Gatherer = require('./gatherer');

class HTML extends Gatherer {
Copy link
Member Author

Choose a reason for hiding this comment

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

super old and unused

@@ -44,18 +44,12 @@ class HTMLWithoutJavaScript extends Gatherer {
return options.driver.evaluateAsync(`(${getBodyText.toString()}())`)
.then(result => {
if (typeof result !== 'string') {
throw new Error('result was not a string');
throw new Error('document body innerText returned by protocol was not a string');
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: document.body.innerText

@@ -21,19 +21,6 @@ const assert = require('assert');
/* eslint-env mocha */

describe('Offline: Service Worker audit', () => {
it('reports driver error when given no Service Worker versions', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

More or less, if I understand what you're asking. Audits never receive an error artifact; runner produces an error audit result for them if any required artifacts are in error. That's tested by the test you linked.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea ok. Just checking we're not losing test coverage.

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

lgtm % extra assertion

}
.evaluateAsync(expression)
.then(returnedValue => {
if (!returnedValue || !Array.isArray(returnedValue.violations)) {
Copy link
Member

Choose a reason for hiding this comment

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

since we're nuking all the remaining checks on the violations array, lets just add an assertion in accessibility-test.js that we throw in this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

good call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants