Testing accessibility using axe-core runs into <title> element not found violation.
Running testcafe with axe-core reports the above mentioned error.
I believe the hammerhead injection is causing the axe-core problem. axe-core cannot find the document title element in the testcafe runner. Hence you see:
Documents must have <title> element to aid in navigation violations.
axe-core should find the <title> element.
https://github.com/donsalari/testcafe-a11y-bug
Your complete test code (or attach your test files):
import { axeCheck, createReport } from 'axe-testcafe';
fixture `Getting Started`
.page `./index.html`;
test('Automated accessibility testing', async t => {
const { error, violations } = await axeCheck(t);
await t.expect(violations.length === 0).ok(createReport(violations));
});
Your complete configuration file (if any):
Your complete test report:
$ testcafe chrome test.js
Running tests in:
- Chrome 83.0.4103.97 / macOS 10.15.5
Getting Started
✖ Automated accessibility testing
1) AssertionError: 1 violations found:
1) Documents must have <title> element to aid in navigation
"html"
: expected false to be truthy
Browser: Chrome 83.0.4103.97 / macOS 10.15.5
3 |fixture `Getting Started`
4 | .page `./index.html`;
5 |
6 |test('Automated accessibility testing', async t => {
7 | const { error, violations } = await axeCheck(t);
> 8 | await t.expect(violations.length === 0).ok(createReport(violations));
9 |});
at <anonymous> (/Users/a0k00e3/Desktop/testcafe-a11y-bug/test.js:8:45)
1/1 failed (1s)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Screenshots:
Although if you run the same static page directly in the browser (without test cafe), axe-core does not report any violations.
axe.run(document, {}, (error, { violations }) => {
console.log({ error, violations });
});
Thank you for your report. I've reproduced the issue. We'll research it and update this thread as soon as we have any news.
Thank you 🎉
Most helpful comment
Thank you for your report. I've reproduced the issue. We'll research it and update this thread as soon as we have any news.