Closed arturhun closed 6 years ago
Please update jest-preset-angular
to 6.0.1
. There's a PR out to address this.
Unfortunately, it does not help. I think for now I am gonna let the solution get stable and documented.
@arturhun @jasedwards Can you provide more details about what did not work after updating jest-preset-angular
?
Specifically, can you post result of npm ls ts-jest
?
My result:
Jasons-MacBook-Pro:oldnxws jason$ npm ls ts-jest
oldnxws@0.0.0 /Users/jason/projects/temp/oldnxws
└─┬ jest-preset-angular@6.0.1
└── ts-jest@23.1.4
@FrozenPandaz Thanks for getting back to me. I don't really recall now what the error was, I would have to run it all over. But again, as I might have run wrong sequence, I think it would be best if we first agree on the sequence to run. So, given the following globals:
Owners-MacBook-Pro:Code owner$ yarn global list
yarn global v1.9.4
info "@angular/cli@6.2.3" has binaries:
- ng
info "@nrwl/schematics@6.4.0-beta.1" has binaries:
- create-nx-workspace
- nx
info "jest@23.6.0" has binaries:
- jest
I should run:
create-nx-workspace myorg
cd myorg
yarn add jest-preset-angular@6.0.1
ng g jest
ng g app jest-app --unit-test-runner jest
Is that correct?
And then, run tests:
ng test jest-app
@arturhun Almost got it. ng g jest
will reset the version of jest-preset-angular
to 6.0.0
.
create-nx-workspace myorg
cd myorg
ng g jest
yarn add jest-preset-angular@6.0.1
ng g app jest-app --unit-test-runner jest
ng test jest-app
@FrozenPandaz Sorry, to have kept you waiting.
So, this jest-preset-angular
version was apparently the reason. The script above works perfectly OOTB for me! Thanks for your effort!
Works also when I add a lib:
ng g lib jest-lib --unit-test-runner jest
ng test jest-lib
We can close this ticket. ...and work on updating the docs :)
Glad your issue is resolved :)
Sorry for the lack of docs. We will work on updating the docs more rigorously.
As a recap:
To fix this issue, install 6.0.1
of jest-preset-anguolar
.
This issue is caused by a transitive dependency, ts-jest
which has a lot of new features in a rewrite of the library. Unfortunately, they do not follow semver
and jest-preset-angular
brought in the latest version in Major version 23 which contained a rewrite and breaking changes as of 23.10.0
(https://github.com/thymikee/jest-preset-angular/issues/195).
We worked with jest-preset-angular
to resolve the issue (https://github.com/thymikee/jest-preset-angular/pull/196) and a migration has been written to automatically migrate workspaces to jest-preset-angular@6.0.1
in the upcoming release of Nx (https://github.com/nrwl/nx/pull/779).
For any concerns about using jest
within Nx, we have seen some substantial reductions in time required to do unit tests with some large projects. Aside from this issue, the feature is working and the current interface is stable and will only improve with upcoming additions of more options for running tests with jest
.
@arturhun @jasedwards Can you provide more details about what did not work after updating
jest-preset-angular
?Specifically, can you post result of
npm ls ts-jest
?My result:
Jasons-MacBook-Pro:oldnxws jason$ npm ls ts-jest oldnxws@0.0.0 /Users/jason/projects/temp/oldnxws └─┬ jest-preset-angular@6.0.1 └── ts-jest@23.1.4
Issue #782 still happened after updating. I did verify I had the correct version of preset. I had to back all of that out so I will need to start over setting it up. I will do that and run npm ls ts-jest when I have time
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.
Below follows a transcript of a session against the new
6.4.0-beta.1
according to instructions provided in #764.Not sure what went wrong. Not sure where I should have run
ng generate jest-project
(as per https://blog.nrwl.io/nrwl-nx-6-3-faster-testing-with-jest-20a8ddb5064).Most probably, before the thing gets stable, we would need a 100% working transcript provided somewhere in the readme.