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

"cypress-axe": "^0.14.0" Blocked by Cors 'unsafe-eval' #127

Open
gchales opened this issue Jun 6, 2022 · 2 comments
Open

"cypress-axe": "^0.14.0" Blocked by Cors 'unsafe-eval' #127

gchales opened this issue Jun 6, 2022 · 2 comments

Comments

@gchales
Copy link

gchales commented Jun 6, 2022

Packages:

        "cypress": "^9.7.0",
        "axe-core": "^4.4.2",
        "cypress-axe": "^0.14.0",

Error:

Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 

Code Triggering Error:

node_modules/cypress-axe/dist/index.js

exports.injectAxe = function () {
    var fileName = typeof (require === null || require === void 0 ? void 0 : require.resolve) === 'function'
        ? require.resolve('axe-core/axe.min.js')
        : 'node_modules/axe-core/axe.min.js';
    cy.readFile(fileName).then(function (source) {
        return cy.window({ log: false }).then(function (window) {

            window.eval(source);  // Triggers Cors error.

        });
    });
};
@djejaquino
Copy link

Maybe there is a more secure way of loading axe script?

@TMUND
Copy link

TMUND commented Feb 16, 2024

Want to add that we are also running into this issue. However, by importing @axe-core/react in our base index.tsx file we are able to run the cy.checkA11y() command without manually doing cy.injectAxe() in the test files.

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

No branches or pull requests

3 participants