component-driven / component-driven/cypress-axe
Doesn't work with Yarn PnP
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 641
- Forks
- 90
- Avg merge
- 6h 8m
- Merged PRs (30d)
- 1
Description
The injectAxe command currently directly looks for the node_modules folder to get axe-core source code. This - however - makes it incompatible with Yarn Plug'n'Play, since it doesn't rely on node_modules.
I worked it around by overwriting the injectAxe command in this way:
Cypress.Commands.overwrite('injectAxe', () => {
cy.task('getAxeSource').then(axeSource =>
cy.window({ log: false }).then(window => {
const script = window.document.createElement('script');
script.innerHTML = axeSource;
window.document.head.appendChild(script);
}),
);
});
And adding this task to my Cypress plugins:
const axe = require('axe-core/axe.js');
module.exports = (on, config) => {
on('task', {
getAxeSource: () => axe.source,
});
};
In this way, the task (that runs in Node) handles the require logic, while the command (that runs in the browser) gets the source from the task and injects it. This would probably also solve https://github.com/component-driven/cypress-axe/issues/73, which is somewhat related.
Let me know if you think this solution makes sense to you. If so, I will open a PR.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the injectAxe command and the Cypress plugins configuration that currently obtains axe-core source from node_modules. Compare that flow with the proposed getAxeSource task and verify that axe-core can be loaded under Yarn Plug'n'Play and injected in the browser without node_modules; done means injectAxe works in a Yarn PnP project.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cypress, typescript
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100