component-driven / component-driven/cypress-axe

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

Open
#134 17 comments 20 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
641
Forks
90
Avg merge
6h 8m
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimum reproduction and e2e/config/cypress.config.ts, then trace how the path for axe-core/axe.min.js is resolved when Cypress is launched with a configuration in a sub-directory. Done means the package resolves from /home/user/dev/project/node_modules rather than the parent directory while preserving behavior for configurations at the project root.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.