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

fix(testing): add support for generating and loading cypress config in ESM format #21471

Merged
merged 1 commit into from
Feb 1, 2024

Conversation

jaysoo
Copy link
Member

@jaysoo jaysoo commented Jan 31, 2024

This PR updates the Cypress configuration generator (@nx/cypress:configuration) and plugin (@nx/cypress/plugin) so that they support generating and consuming config files in ESM format respectively.

There are two issues:

  1. The configuration generator creates cypress.config.js with import/export, which does not work unless the workspace/project has type: 'module' in package.json.
  2. The plugin reads the cypress config file using require, which does not work with ESM format.

Changes:

  1. Differentiate between .ts and .js (ESM) and .js (CJS) formats when generating the cypress config file.
  2. Switch to dynamic import when reading cypress config file, which works with both ESM and CJS formats.

Current Behavior

ESM format .js files are broken

Expected Behavior

ESM format .js files work

Related Issue(s)

Fixes #

@jaysoo jaysoo requested a review from a team as a code owner January 31, 2024 21:46
Copy link

vercel bot commented Jan 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2024 7:35pm

@jaysoo jaysoo force-pushed the fix_cypress_esm branch 2 times, most recently from 7dbf299 to 3ccef05 Compare February 1, 2024 18:40
@jaysoo jaysoo requested a review from a team as a code owner February 1, 2024 18:40
@jaysoo jaysoo requested a review from mandarini February 1, 2024 18:40
@jaysoo jaysoo enabled auto-merge (squash) February 1, 2024 19:51
@jaysoo jaysoo merged commit 79648bc into nrwl:master Feb 1, 2024
6 checks passed
@jaysoo jaysoo deleted the fix_cypress_esm branch February 1, 2024 22:30
FrozenPandaz pushed a commit that referenced this pull request Feb 2, 2024
Copy link

github-actions bot commented Feb 7, 2024

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants