Skip to content

Cypress does not resolve CT Framework Definition in monorepo with hoisted node_modules #25993

Closed
@lmiller1990

Description

@lmiller1990

Current behavior

Cypress does not resolve CT Framework Definition correctly in monorepos with hoisted modules.

Desired behavior

Should correctly resolve.

Test code to reproduce

Use a monorepo, eg https://github.com/lmiller1990/ct-monorepo-bug

  • yarn install
  • notice @lmiller1990/cypress-ct-solid-js is in the root node_modules
  • cd packages/foo
  • yarn cypress open
  • Select CT
  • Notice Solid.js is NOT shown in the list

Problem is we can't just require.resolve - we first need to find all node_modules matching the cypress-ct- glob. We currently do this by globbing the projectRoot - that's where the Cypress project is currently, so in this case it'll be packages/foo/node_modules/cypress-ct-*. Code here:

const fullPathGlobs = [
path.join(projectRoot, CT_FRAMEWORK_GLOBAL_GLOB),
path.join(projectRoot, CT_FRAMEWORK_NAMESPACED_GLOB),
].map((x) => x.replaceAll('\\', '/'))
const packageJsonPaths = await globby(fullPathGlobs)
debug('Found packages matching %s glob: %o', fullPathGlobs, packageJsonPaths)

We need to recursively check up to the workspace root, I think - how you identify this, I'm not sure (eg if we are in an Nx repo, how to know the top level? Yarn monorepo? Other type of repo)?

Cypress Version

12.7.0

Node version

v16.17

Operating System

All

Debug Logs

n/a

Other

n/a

Metadata

Metadata

Assignees

Labels

CTIssue related to component testing

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions