-
Notifications
You must be signed in to change notification settings - Fork 791
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
feat: add environment details to results #1353
Conversation
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.
Please add these new properties to the TypeScript definition file.
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.
Comments and questions left inline.
lib/core/reporters/na.js
Outdated
@@ -9,7 +9,25 @@ axe.addReporter('na', function(results, options, callback) { | |||
} | |||
|
|||
var out = helpers.processAggregate(results, options); | |||
var orientation = |
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.
We should probably use the standards-compliant object first:
var orientation = screen.orientation || screen.msOrientation || screen.mozOrientation || {}
Just incase someone defined a non-standard property of the same name.
Not a big deal either way tho.
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.
We could, I just copied the MDN code to grab it https://developer.mozilla.org/en-US/docs/Web/API/Screen/orientation
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.
🤷♀️ OK, that's fine I suppose
lib/core/reporters/no-passes.js
Outdated
@@ -9,8 +9,25 @@ axe.addReporter('no-passes', function(results, options, callback) { | |||
options.resultTypes = ['violations']; | |||
|
|||
var out = helpers.processAggregate(results, options); | |||
var orientation = |
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.
Is it worth moving this into a getScreenOrientation
function since it's duplicated across files?
Again, not a big deal IMO, just a thought.
test/core/reporters/na.js
Outdated
@@ -245,4 +245,25 @@ describe('reporters - na', function() { | |||
done(); | |||
}); | |||
}); | |||
it('should add version information', function(done) { | |||
axe.run(naOption, function(err, results) { | |||
try { |
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.
This try/catch
seems very awkward. Can't we just do:
axe.run(naOption, function (err, results) {
if (err) {
return done(err)
}
// Assertions go here
done()
})
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.
The try/catch
is for the assertions. A failed assertion throws an error but done
is not called with it, so the unit test just hangs until timeout, then stops the test there without reporting what the error was.
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.
Ohh, wow, OK. That's something we should change. I wonder if updating mocha
would solve the problem for us.
Obviously don't worry about this now.
test/core/reporters/no-passes.js
Outdated
@@ -209,4 +209,25 @@ describe('reporters - no-passes', function() { | |||
done(); | |||
}); | |||
}); | |||
it('should add version information', function(done) { | |||
axe.run(noPassOpt, function(err, results) { | |||
try { |
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.
Same comment about the try/catch
.
test/core/reporters/v1.js
Outdated
@@ -283,4 +283,25 @@ describe('reporters - v1', function() { | |||
done(); | |||
}); | |||
}); | |||
it('should add version information', function(done) { | |||
axe.run(optionsV1, function(err, results) { | |||
try { |
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.
Same comment about the try/catch
.
test/core/reporters/v1.js
Outdated
try { | ||
assert.isNull(err); | ||
assert.isObject(results.testEngine, 'tesetEngine'); | ||
assert.equal(results.testEngine.name, 'axe-core'); |
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.
Why are we testing the same thing 3 different times? Is there a case where 1 of these tests could fail but the others wouldn't? If not, I think we only need to do this once.
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.
These are different reporters. Just answered my own question. Disregard my question.
test/core/reporters/v2.js
Outdated
@@ -227,4 +227,25 @@ describe('reporters - v2', function() { | |||
done(); | |||
}); | |||
}); | |||
it('should add version information', function(done) { | |||
axe.run(optionsV2, function(err, results) { | |||
try { |
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.
Same duplicate test and try/catch
concern.
Made more sense of this after speaking with Steven
lib/core/reporters/na.js
Outdated
@@ -9,7 +9,25 @@ axe.addReporter('na', function(results, options, callback) { | |||
} | |||
|
|||
var out = helpers.processAggregate(results, options); | |||
var orientation = | |||
screen.msOrientation || (screen.orientation || screen.mozOrientation || {}); |
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 don't think we can assume screen exists as a global (or at all). I kinda doubt this is available on IE9. Please check that it exists before accessing its properties.
lib/core/reporters/na.js
Outdated
windowHeight: window.innerHeight, | ||
orientationAngle: orientation.angle, | ||
orientationType: orientation.type | ||
}, |
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.
Instead of duplicating this code a bunch of times, it'd be better to create a helper for this in lib/core/reporters/helpers
, so you could just do:
callback({
...getEnvironmentData(),
toolOptions: options,
violations: out.violations,
passes: out.passes,
incomplete: out.incomplete,
inapplicable: out.inapplicable
})
You could probably have the URL & timestamp returned from it too. That's probably a better place for those two than the processAggregate helper.
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.
@WilcoFiers please see #1353 (comment)
We've discussed this already, but neither @straker nor I know where to put things like this.
Adds tool options, axe-core version, branding name, and environment details to the result object.
Closes issue: #947
Reviewer checks
Required fields, to be filled out by PR reviewer(s)