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

@cypress/webpack-preprocessor cleanseError throws TypeError #5906

Closed
rkrisztian opened this issue Jun 6, 2021 · 5 comments
Closed

@cypress/webpack-preprocessor cleanseError throws TypeError #5906

rkrisztian opened this issue Jun 6, 2021 · 5 comments
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug

Comments

@rkrisztian
Copy link

rkrisztian commented Jun 6, 2021

I have a typical installation of Cypress as told here:

https://nx.dev/latest/angular/cypress/overview

However, I have modified the support/index.ts, it contains an error, and I don't see a good explanation for it. What I get instead is:

  Running:  app.spec.ts                                                                     (1 of 1)
Starting type checking service...
Using 1 worker with 2048MB memory limit
Starting type checking service...
Using 1 worker with 2048MB memory limit

The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file (`/home/rkrisztian/my-project/apps/app-e2e/src/plugins/index.js`)

 TypeError: err.replace is not a function
    at cleanseError (/home/rkrisztian/my-project/node_modules/@cypress/webpack-preprocessor/index.js:229:14)
    at Array.map (<anonymous>)
    at handle (/home/rkrisztian/my-project/node_modules/@cypress/webpack-preprocessor/index.js:132:10)
    at finalCallback (/home/rkrisztian/my-project/node_modules/webpack/lib/Compiler.js:415:32)
    at /home/rkrisztian/my-project/node_modules/webpack/lib/Compiler.js:432:13
    at Hook.eval [as callAsync] (eval at create (/home/rkrisztian/my-project/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/rkrisztian/my-project/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
    at onCompiled (/home/rkrisztian/my-project/node_modules/webpack/lib/Compiler.js:430:21)
    at /home/rkrisztian/my-project/node_modules/webpack/lib/Compiler.js:1106:17
    at Hook.eval [as callAsync] (eval at create (/home/rkrisztian/my-project/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/rkrisztian/my-project/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
    at /home/rkrisztian/my-project/node_modules/webpack/lib/Compiler.js:1102:33
    at /home/rkrisztian/my-project/node_modules/webpack/lib/Compilation.js:2525:11
    at Hook.eval [as callAsync] (eval at create (/home/rkrisztian/my-project/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/rkrisztian/my-project/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
    at /home/rkrisztian/my-project/node_modules/webpack/lib/Compilation.js:2518:38
    at eval (eval at create (/home/rkrisztian/my-project/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:17:1)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

This makes debugging harder.

This is in fact the same error as described in cypress-io/cypress#8948 .

But because of an indirect dependency on cypress-webpack-preprocessor, I can't replace it with cypress-webpack-preprocessor-v5.

@rkrisztian rkrisztian changed the title webpack-preprocessor cleanseError throws TypeError @cypress/webpack-preprocessor cleanseError throws TypeError Jun 6, 2021
@vsavkin vsavkin added the scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx label Jun 17, 2021
@jogelin
Copy link
Contributor

jogelin commented Jul 7, 2021

Same here, this is the last issue that blocks my migration to Angular 12 :(

@PendletonJones
Copy link

PendletonJones commented Jul 8, 2021

I was able to resolve this by just deleting the plugins/index.js as well as the reference to it in cypress.json as Cypress now has built in support for typescript and does not require the preprocessTypescript function.

I also do have cypress-webpack-preprocessor-v5 installed as it was suggested in the linked issue on the Cypress repo but I haven't tested removing it yet to see if it actually makes any difference.

FWIW I generated my project a long time ago apparently sometime before Cypress had built-in support for Typescript.

I'm on the latest version of Nx tools: 12.5.6 and "cypress": "7.7.0"

@jogelin
Copy link
Contributor

jogelin commented Jul 8, 2021

@PendletonJones it is working indeed!

Same use case, repository generated a long time ago and didn't know that Cypress supported typescript by default.

I didn't remove the plugin file because I am using other plugins. I just commented on('file:preprocessor', preprocessTypescript(config)). I didn't install cypress-webpack-preprocessor-v5 too.

I am just confused, what is the added value of preprocessTypescript provided by Nx? Because it is still added in the generation of the last version.

@rkrisztian
Copy link
Author

@jogelin , you might have heard that preprocessTypescript is deprecated now.

I'm going to close this issue because with those changes the TypeError: err.replace is not a function isn't an issue anymore.

@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
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug
Projects
None yet
Development

No branches or pull requests

4 participants