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

feat(nextjs): can set compiler when setting up nxComponentTestingPreset #19171

Merged
merged 21 commits into from
Nov 3, 2023

Conversation

erenken
Copy link
Contributor

@erenken erenken commented Sep 14, 2023

Currently nextjs only uses the swa compiler in Cypress component testing.

To use @cypress/code-coverage you need to use babel, you can now select which compiler to use.

closed #19131

Current Behavior

Cypress Code Coverage doesn't work in a next project when using nxComponentTestingPreset from @nx/next/plugins/component-testing. Currently it works if you are using a react project and importing nxComponentTestingPreset from @nx/react/plugins/component-testing, but tests using NavLink fail because they are missing process with using this preset.

Expected Behavior

I would expect Cypress Code Coverage to work in a next and react project.

Related Issue(s)

Fixes #19131

Unable to run test on devcontainer, so that was updated to use latest version.

…set`

Currently nextjs only uses the *swa* compiler

To use @cypress/code-coverage you need to use *babel*, you can now select which compiler to use.

closed nrwl#19131
@erenken erenken requested review from a team as code owners September 14, 2023 15:05
@erenken erenken requested a review from mandarini September 14, 2023 15:05
@vercel
Copy link

vercel bot commented Sep 14, 2023

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

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview 💬 Add feedback Nov 3, 2023 3:11am

@mandarini
Copy link
Member

Hey @erenken thanks for this PR! Can you please add some more tests around this?

@mandarini
Copy link
Member

@erenken changes look good, we just need a few tests around this and the pipelines to pass! :D Just ping me when you're done and I will merge! Thank you for this PR!

@mandarini mandarini self-assigned this Oct 4, 2023
@erenken
Copy link
Contributor Author

erenken commented Oct 10, 2023

@erenken changes look good, we just need a few tests around this and the pipelines to pass! :D Just ping me when you're done and I will merge! Thank you for this PR!

Are there any existing tests for the nxComponentTestingPreset method? I was trying to find them, and I couldn't find anything that executes the method. The only tests that have nxComponentTestingPreset in them are all doing contains or snapshot comparisons.

Just adding the line:

const result = nxComponentTestingPreset('myFile.json', {});

Produces this error:

    /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /workspaces/nx/packages/nx/src/native/nx.linux-x64-gnu.node)

      180 |           try {
      181 |             if (localFileExisted) {
    > 182 |               nativeBinding = require('./nx.linux-x64-gnu.node')
          |                               ^
      183 |             } else {
      184 |               nativeBinding = require('@nx/nx-linux-x64-gnu')
      185 |             }

      at CompileFunctionRuntime._loadModule (../../node_modules/.pnpm/jest-runtime@29.5.0/node_modules/jest-runtime/build/index.js:1009:29)
      at Object.<anonymous> (../nx/src/native/index.js:182:31)
      at Object.<anonymous> (../nx/src/hasher/task-hasher.ts:23:1)
      at Object.<anonymous> (../nx/src/hasher/hash-task.ts:4:1)
      at Object.<anonymous> (../nx/src/tasks-runner/task-orchestrator.ts:21:1)
      at Object.<anonymous> (../nx/src/tasks-runner/default-tasks-runner.ts:2:1)
      at Object.<anonymous> (../devkit/nx-reexports-pre16.ts:209:1)
      at Object.<anonymous> (../devkit/index.js:21:20)
      at Object.<anonymous> (../cypress/src/utils/ct-helpers.ts:2:1)
      at Object.<anonymous> (plugins/component-testing.ts:1:1)
      at Object.<anonymous> (plugins/component-testing.spec.ts:1:1)

When I comment out that line no errors and the tests pass. Any recommendations? I am running in the devcontainer.

I did run

sudo apt update
sudo apt upgrade

Also tried install libc6 and get libc6 is already the newest version (2.31-13+deb11u7).

Well, hey, I got passed that error. I had to update the devcontainer.json to use a newer image:

"image": "mcr.microsoft.com/devcontainers/typescript-node:latest"

@erenken
Copy link
Contributor Author

erenken commented Oct 10, 2023

Never mind, I got it all working after updating the devcontainer. Pushing tests soon.

…set`

Currently nextjs only uses the *swa* compiler

To use @cypress/code-coverage you need to use *babel*, you can now select which compiler to use.

closed nrwl#19131
@erenken erenken requested review from FrozenPandaz, vsavkin and a team as code owners October 10, 2023 03:21
@mandarini
Copy link
Member

@barbados-clemens adding you in this conversation to take a look! :D

…set`

Currently nextjs only uses the *swa* compiler

To use @cypress/code-coverage you need to use *babel*, you can now select which compiler to use.

closed nrwl#19131
…set`

Currently nextjs only uses the *swa* compiler

To use @cypress/code-coverage you need to use *babel*, you can now select which compiler to use.

closed nrwl#19131
…set`

Currently nextjs only uses the *swa* compiler

To use @cypress/code-coverage you need to use *babel*, you can now select which compiler to use.

closed nrwl#19131
@erenken
Copy link
Contributor Author

erenken commented Nov 2, 2023

@mandarini I got all the changes that you and @barbados-clemens wanted. I removed the packages I added to packages.json and created E2E test, and everything is passing. If I missed something or you need more, please let me know. I would like to get this merged in so we can get code coverage working in our project.

Copy link
Contributor

@barbados-clemens barbados-clemens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the package.json changes are still there can you revert those real quick?

.devcontainer/devcontainer.json Outdated Show resolved Hide resolved
pnpm-lock.yaml Outdated Show resolved Hide resolved
…set`

Currently nextjs only uses the *swa* compiler

To use @cypress/code-coverage you need to use *babel*, you can now select which compiler to use.

closed nrwl#19131
…set`

Currently nextjs only uses the *swa* compiler

To use @cypress/code-coverage you need to use *babel*, you can now select which compiler to use.

closed nrwl#19131
…set`

Currently nextjs only uses the *swa* compiler

To use @cypress/code-coverage you need to use *babel*, you can now select which compiler to use.

closed nrwl#19131
…set`

Currently nextjs only uses the *swa* compiler

To use @cypress/code-coverage you need to use *babel*, you can now select which compiler to use.

closed nrwl#19131
…set`

Currently nextjs only uses the *swa* compiler

To use @cypress/code-coverage you need to use *babel*, you can now select which compiler to use.

closed nrwl#19131
@erenken
Copy link
Contributor Author

erenken commented Nov 3, 2023

I know it looks like the main-linux failed, but I think it just needs to be re-ran. I have found that these pipelines are very temperamental and the only way to re-run them is to commit a change or update from master. It was working before the last update from master.

@mandarini mandarini merged commit e8b6034 into nrwl:master Nov 3, 2023
2 checks passed
@erenken erenken deleted the next-component-testing-compiler branch November 3, 2023 15:18
Copy link

github-actions bot commented Nov 9, 2023

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 Nov 9, 2023
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.

Cypress Code Coverage and nextjs
3 participants