question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Resolved path for `axe-core/axe.min.js` is incorrect if the Cypress Config is in a sub-directory when using Cypress v10+

See original GitHub issue

axe-core/axe.min.js cannot be loaded if the Cypress config is contained in a sub directory. The resolved path traverses from the location of the config, but starts at the project root where the command was invoked.

This seems to be due to require.resolve returning the path relative to the configuration file, whereas when running in Cypress Versions <10 require.resolve returns the path relative to the directory the initial command was invoked.

So assuming a project with a directory structure of:

/home/user/dev/project/
- e2e/
  - config/
    - cypress.config.ts
- src/
- node_modules/
- package.json

The path we attempt to require for axe-core/axe.min.js will be /home/user/dev/node_modules/axe-core/axe.min.js.

A minimum reproduction can be found using my fork of this repo.

image

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:17
  • Comments:12

github_iconTop GitHub Comments

1reaction
AriPerkkiocommented, Dec 2, 2022

This seems to be due to require.resolve returning the path relative to the configuration file, whereas when running in Cypress Versions <10 require.resolve returns the path relative to the directory the initial command was invoked.

This all sounds exactly as the upstream issue: https://github.com/cypress-io/cypress/issues/22689. It makes no sense that all plugins in the ecosystem start patching themselves due to a bug in Cypress. Code coverage plugin is also seeing this: https://github.com/cypress-io/code-coverage/issues/586.

Work-around for now: https://github.com/cypress-io/cypress/issues/22689#issuecomment-1211732120

1reaction
ismaycommented, Nov 11, 2022

If that fixes it for you it would be good to submit your patch as a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

config changes working directory, Cypress 9 -> 10/11/12 #22689
Current behavior In after:run task, Cypress 10 is using the location of configuration file as current working directory. In Cypress 9 it is ......
Read more >
Configuration - Cypress Documentation
This guide is for Cypress 10 and the new JavaScript configuration file format. If you are on an older version of Cypress that...
Read more >
Cypress.config
Configuration set using Cypress.config is only in scope for the current spec file. Cypress runs each spec file in isolation: the browser is...
Read more >
Component Testing Config - Cypress Documentation
When you launch Cypress for the first time in a project, the app will automatically guide you through setup and configuration. You don't...
Read more >
Web Security - Cypress Documentation
visit() command is issued in a test, Cypress changes its URL to match the origin of your remote application, thereby solving the first...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found