How to only log violations while running tests
pgroot91 opened this issue · 6 comments
Hi Guys,
Is it possible to report/log accessibility violations only and not making our tests to fail?
Patrick
Test fails only due to this assertion : https://github.com/avanslaars/cypress-axe/blob/6f7887c03fdd26ac3bef7de1c1a00353692ea67d/index.js#L41
I think we can pass it as argument to enable disable the fail mode/assertion which will avoid the tests to fail. Additionally you would like to log the violations and for that can use cy.log
to display the violations.
Test fails only due to this assertion :
https://github.com/avanslaars/cypress-axe/blob/6f7887c03fdd26ac3bef7de1c1a00353692ea67d/index.js#L41
I think we can pass it as argument to enable disable the fail mode/assertion which will avoid the tests to fail. Additionally you would like to log the violations and for that can use
cy.log
to display the violations.
I received quite some emails asking about how to achieve this so I think its best to update in this thread :
I forked the repo and created a solution here :
https://github.com/chit786/cypress-axe/blob/e38ea0636e9207815e373040f74478efac50c878/index.js#L16
And this is how you I am handling it :
https://github.com/chit786/cypress-axe/blob/e38ea0636e9207815e373040f74478efac50c878/index.js#L55
So in nutshell the workflow will be :
- create a cypress environment variable and set the skipTests flag to true/false and pass it as fourth argument to the cy.checkA11y() command.
Hope this helps :)
@chit786 Really appreciate it for showing us how to use it! 👍 Will give it a try soon.
@pgroot91 i created a pull request on this project with the solution . Can you please reopen this issue so that it can be closed once the changes are merged or a solution is there .. it’s an interesting functionality to have :)
The PR with the fix for this has been merged and is included in 0.6.0
release
i dont understand how to solve this problem. can anyone assist?