简体   繁体   中英

My cypress tests are crashing du to pluginsFile, why?

I am facing some problem with cypress and typescript on a project. When I try to setup cypress with typescript in a new project things go well. When I do the exact same things in an another big project I have an error when I run cypress run the cypress browser open, then when I click on a test a browser open and crash with this stack trace on my terminal.

We stopped running your tests because a plugin crashed.

Your pluginsFile threw an error from: /home/xxxxx/Desktop/workspace/trouve-ui-13/src/web_app/cypress/plugins/index.ts

TypeError: SizeOnlySource is not a constructor
    at updateFileWithReplacementSource (/home/xxxxx/Desktop/workspace/trouve-ui-13/src/web_app/node_modules/webpack/lib/Compiler.js:740:37)
    at updateWithReplacementSource (/home/xxxxx/Desktop/workspace/trouve-ui-13/src/web_app/node_modules/webpack/lib/Compiler.js:722:8)
    at processExistingFile (/home/xxxxx/Desktop/workspace/trouve-ui-13/src/web_app/node_modules/webpack/lib/Compiler.js:756:8)
    at /home/xxxxx/Desktop/workspace/trouve-ui-13/src/web_app/node_modules/webpack/lib/Compiler.js:825:10
    at callback (/home/xxxxx/Desktop/workspace/trouve-ui-13/src/web_app/node_modules/graceful-fs/polyfills.js:299:20)
    at callback (/home/xxxxx/.cache/Cypress/9.5.3/Cypress/resources/app/node_modules/graceful-fs/polyfills.js:299:20)
    at FSReqCallback.oncomplete (node:fs:199:5)

I don't have any plugin and here is the content of plugins/index.ts

export default (on, config) => {
  return config;
};

Anyone help would be appreciated?

I tried removing node_modules and yarn.lock and reinstalling it.

I expected the tests to run

Try use:

module.exports = (on, config) => {
  return config;
};

instead of export default, this should work, if not please let me know

Best regards, Caíque Coelho

As pointed in the comment below , I had two versions of webpack-sources coming from different dependencies. Specifying "webpack-sources": "^3.2.0" in my devDependencies solved my problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM