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

Deprecate @nrwl/cypress/plugins/preprocessor #3037

Closed
AlexAegis opened this issue May 19, 2020 · 7 comments
Closed

Deprecate @nrwl/cypress/plugins/preprocessor #3037

AlexAegis opened this issue May 19, 2020 · 7 comments
Labels
blocked: more info needed outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx stale

Comments

@AlexAegis
Copy link

In the generated index.js pluginFile of cypress the nx helper is there to preprocess TS Files.

  // Preprocess Typescript file using Nx helper
  on('file:preprocessor', preprocessTypescript(config));

Since Cypress 4.4.0 (4/13/2020), it supports typescript out of the box

Added support for TypeScript without needing your own transpilation through preprocessors.

https://docs.cypress.io/guides/tooling/typescript-support.html#History

If the nx preprocessor is more than that, then please clarify in the comment why it's needed.

In a fresh project I tried to run e2e with the plugin removed and it ran fine. But then again, that was an empty workspace with a blank angular app.

@FrozenPandaz FrozenPandaz added blocked: more info needed scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx labels May 21, 2020
@FrozenPandaz
Copy link
Collaborator

I agree, let's start investigating by opening a PR against https://github.com/nrwl/nx-examples with the preprocessor removed to see if everything works as expected there.

@demisx
Copy link

demisx commented May 21, 2020

Will Nx migrate us to Cypress v4 when ready or will we have to do it manually? I've tried the latter, but running into similar issue. Should we stick with v3.x for now?

@george43g
Copy link

The latest Cypress has TS support built-in. I'm not sure what this means about the preprocessor hook personally - check out this thread for more info: cypress-io/cypress#5906

But I wanted to point out a couple of important points:
In the default schematic, the generated cypress.json file should have a few changes made:
the pluginsFile needs to point directly to plugins/index.ts with the file extension. The default from when I set it up earlier in the year was plugins/index. This caused a crash.

This means that the default pluginsFile also needs to be updated to TS. I actually suspect that their preprocessor does a little more than transpile - it also had some tsconfig paths module in its source code and I suspect this is set up this way in order to be able to resolve the library paths as configured in the paths property in tsconfig. This is generally a pain point with tsc and is why they use webpack to bundle apps in NX. In order to be able to resolve these library paths while running ts-node, I think you might need extra functionality in the preprocessor, hence why they built their own rather than using the one that was available previously to the Cypress community.

It would be really helpful to be able to not only write plugins in TS, but also be able to require TS libraries from within the plugins file!

I also think that typescript: 'project' is a setting that should be set as well (please double-check this as I only had a cursory glance) but I'm not sure where from. I just know it's checked in the Cypress source code.

@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@tstackhouse
Copy link

Looks like this got marked as stale and closed out when it probably shouldn't have.

@eulersson
Copy link

If I simply remove the on('file:preprocessor... line, in an Angular nx monorepo, I get errors:

Error: Webpack Compilation Error
/Users/ramon/Watchity/frontend/libs/shared/ui/src/index.ts 15:9
Module parse failed: Unexpected token (15:9)
File was processed with these loaders:
 * ../../../../Library/Caches/Cypress/7.5.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/ts-loader/index.js
You may need an additional loader to handle the result of these loaders.

See my full log in the related issue #5713

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: more info needed outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx stale
Projects
None yet
Development

No branches or pull requests

6 participants