-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
react component testing: Cannot find get-package-type/index via nyc #14194
Comments
Can you include your entire |
Okay, I've got my plugins/index.ts below. // plugins/index.ts
module.exports = (on, config) => {
// from the root of the project (folder with cypress.json file)
config.env.webpackFilename = 'webpack.config.js'
require('@cypress/react/plugins/load-webpack')(on, config)
// IMPORTANT to return the config object
// with the any changed environment variables
return config
} |
By the way, I might be able to make a reproducible test case. In my work repro I managed to get past this error by changing my
|
@ahfarmer Yeah, Cypress reads in your tsconfig at the root of the project and applies the same rules to Cypress. There are some current bugs with this that you may have encountered. A reproducible example would be great. |
Okay here you go, just run |
I can recreate the error with the following:
{
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/preset-react": "^7.12.10",
"@cypress/react": "^4.16.0",
"babel-loader": "^8.2.2",
"ts-loader": "^8.0.12",
"typescript": "^4.1.3",
"webpack": "4"
},
"dependencies": {
"cypress": "^6.1.0"
}
}
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": ["*", "./node_modules/*"]
}
}
}
module.exports = (on, config) => {
require('@cypress/react/plugins/load-webpack')(on, config)
} |
Looks like @cypress/code-coverage might be the culprit 🤔 Yep:
Ultimately Let's figure out what's broken and fix it. |
I had this issue using the old cypress-react-unit-test package and it was fixed by dependency updates in that package. I think 🤞 this #14165 recently merged PR along with setting |
I will try and verify that is true! I also would like code coverage to work. Having a work-around in place is good too, though, since we are rapidly iterating on component testing (stay tuned :D) |
Unfortunately the latest release did not fix this for me. I had a similar issue when using react-cypress-unit-test that was resolved when the packages were updated and when coverage: false(cypress-io/cypress-react-unit-test#488 (comment)) would ignore coverage but this is not working with @cypress/react |
🤔 will try look into this again. |
When I explicitly set |
Hmm, we'll look into this with the context of #8090 -- thanks for sticking through this and finding a workaround. It'll help get to the root 👍🏻 |
Thank you. Do you have any other suggestions on anything else to try. TS_NODE_PROJECT=0 works when running on my ci but when running locally on a mac it causes my web server to stop. |
I am hitting this today with Cypress 7.2.0 running locally on Windows. I'm not sure exactly where I should add TS_NODE_PROJECT=0, but have sprinkled it around all my .env files to no effect. I've also tried modifying my .tsconfig to include Edit: Seems like just like @anark it's now working on my CI, but failing locally. |
Have you tried setting
in your |
Thanks for the suggestion, but I'm actually trying to enable code-coverage! I may start a new thread in https://github.com/cypress-io/code-coverage/issues. |
@ahfarmer, this issue seems to be stale. Is there anything to follow up on here? Have you tried the latest version of Cypress component testing (v10)? |
@rockindahizzy I'm not working on my cypress project anymore, so I haven't tested this with newer versions of Cypress. |
Current behavior
When I run
cypress run
without using component testing, everything works fine. But when I add this line to myplugins/index.ts
:require("@cypress/react/plugins/load-webpack")(on, config);
I get the following error:
Test code to reproduce
I haven't been able to isolate the problem yet. I'm not sure where to begin.
Versions
Tested with Cypress 6.0.0, 6.0.1 and 6.1.0 - all produce the same error.
More Info
It looks like this is related to code coverage. I'm not trying to use code coverage, but
nyc
is getting imported, and then it is trying to importget-package-type/index
. Theget-package-type
module does exist in node_modules, but it is a .cjs file:node_modules/get-package-type/index.cjs
. It seems like the Cypress loader is not looking for.cjs
extensions in my particular scenario. I'm not sure why Cypress is normally able to find.cjs
files but not in my particular case.The text was updated successfully, but these errors were encountered: