-
Notifications
You must be signed in to change notification settings - Fork 51
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
nx test: Jest unit tests are failing to run in any test that has been imported from other libraries #245
Comments
I ran into this when I first tried to test .vue files. I do have a project in my solution that is running tests against Vue files. I wish I had written down what I did to get it working. I am also running into this now with another situation where I have a portion of the app that imports the language strings from Vuetify so that I can switch languages. This is a pure TS file with no other Vue in sight and I am getting the same error from Jest. I have tried to make my config for this new library match the config of the libarary that can test Vue files but nothing has worked. If I find a solution, I will post back here.
|
Looking at your nx report, how did you get setup with 13.10.3? I found that 13.10 failes to apply the patch for .vue files. Maybe that is the issue for you. Try moving Nx to 13.9.7, which is the last version of 13.9 that works with Nx-Plus/vue. |
This doesn't help your problem (I cloned your reporoduction repo and tried), but for my problem I finally found a solution. I am putting it here because the symptoms of my problem were exactly the same message from jest. My problem was that i was importing a TS file from node_modules and jest was choking on the import of that TS file with exactly the same message above. I finally found a fix for it by putting this statement into my
Then I also had to add a compiler flag to this library's
The first time I ran the tests it seemed to take forever (45 seconds to run 3 fairly simple test files), but after that it runs quickly. I am going to assume that this negatively affects performance and therefore only put it in the libs that require it. BTW, I also found that the |
Hey @gregveres! Thanks for your time and help. I did step by step your possible solution but got no success, I got stuck in the same issue. For your issue, it seems that your problem was inside |
Hi @Ricardo385 For my case, I am making progress on converting to Nx now. I have 1 app and 43 libraries so far. I expect to end up with 4 apps and over 200 libraries. I am disappointed that I need so many libraries, but from what I have seen, you need a library for every component that you are going to dynamically load using the Vue Router. The router will end up pulling in everything in the library. Here are my steps for creating a new library. Then I start modifying the files that were created. Then I modify these files in the project:
I am running into an infinite loop in jest when it is processing my TS files that happens randomly. So at this point my unit tests randomly fail. Well, randomly is a bit less random. Out of the 35 unit test projects, at least 5 will fail each run, but it will be a different set of 5 each time. I then execute the command again and they will all pass. I have to try and track that down too. I will first try to upgrade to jest 28 to see if that fixes it. |
Hey, Just wanted to let you know I found a workaround, is working pretty well so far, let's see how it goes in the next weeks when I start creating new tests ;) https://www.marimendez88.dev/posts/nx-vue-jest-support |
Current Behavior
An NX - Ionic and Vue workspace fails to run tests, many solutions tested and any seems to fix the issue:
This is the error message:
Solutions tested:
Related Issues:
nrwl/nx#8323
nrwl/nx#7844
nrwl/nx#8354
nrwl/nx#9825
ionic-team/ionic-framework#25223
Investigation made:
import { registerTsProject } from 'nx/src/utils/register';
always mark an error because is not recognizable.Expected Behavior
Steps to Reproduce
Here you can find a minimal repository to reproduce the issue:
https://github.com/marimendez88/of-jest-issue
npm install @nrwl/cypress@^13.0.0 @nrwl/jest@^13.0.0 @nrwl/linter@^13.0.0 --save-dev
npm install @nx-plus/vue --save-dev
nx g @nx-plus/vue:app sample-app
npm i @ionic/vue npm i @ionic/vue-router
nx g @nx-plus/vue:lib sample-lib
Failure Logs
This is the error message:
Environment
The text was updated successfully, but these errors were encountered: