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

feat: Don't bundle axe-core #69

Merged
merged 1 commit into from
Oct 27, 2020
Merged

feat: Don't bundle axe-core #69

merged 1 commit into from
Oct 27, 2020

Conversation

sapegin
Copy link
Member

@sapegin sapegin commented Oct 27, 2020

This allows consumers to use their own version of axe-core and significantly reduces the installation size. Also allow any 3.x or 4.x versions of axe-core in peer dependencies.

Closes #65, closes #59

This allows consumers to use their own version of axe-core and significantly reduces the installation size. Also allow any 3.x or 4.x versions of axe-core in peer dependencies.

Closes #65, closes #59

export const injectAxe = () => {
cy.window({ log: false }).then((window) => {
window.eval(axe);
window.eval(axe.source);
Copy link

Choose a reason for hiding this comment

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

Using axe.source will use the source from axe-core in cypress-axe's dependencies (not the main project). Thus it'll be locked to axe-core ^4.0.2.

To reproduce this issue, after installing cypress-axe, try installing the peer dependencies:

npm install --save-dev cypress  axe-core@3.5.5

Once you run cy.injectAxe() and cy.checkA11y(), you can see the injected axe-core version is 4.0.2 (not 3.5.5).
Rather than using axe.source, I recommend using cy.readFile(), so the implementation will be:

export const injectAxe = () => {
	cy.readFile('node_modules/axe-core/axe.min.js').then((content) => {
		cy.window({ log: false }).then((window) => {
			window.eval(content);
		});
	})
};

I tested this implementation, and it successfully changes the axe-core version to 3.5.5 (for the scenario above)

Copy link
Member Author

Choose a reason for hiding this comment

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

There's no bundled axe-core anymore in pull request, it's coming from your project's dependencies.

Choose a reason for hiding this comment

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

Yes, I understand it's not bundled anymore.
Perhaps, I encountered this issue because I tested this change with npm link.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've tried to copy the built file into my project's node_modules. Not sure it's much better than linking ;-)

Choose a reason for hiding this comment

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

probably copy-pasting the built file is more suitable in this case. When I tested that way, this change works as expected 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool, then I'm going to merge this and we could test the real thing and see what other issues we'll have ;-)

@sapegin sapegin merged commit 71e3a50 into master Oct 27, 2020
@sapegin sapegin deleted the no-bundle branch October 27, 2020 17:11
@github-actions
Copy link

🎉 This PR is included in version 0.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Allow users to use any version of axe core
2 participants