Hello!
Thanks for your work on this. I've upgraded to 7.0.0-alpha.2 and things seem to be a bit broken. Currently most tests fail with an error message of: Error: Uncaught (in promise): Failed to load button.component.html.
Here's the Jest config:
"jest": {
"preset": "jest-preset-angular",
"setupFiles": [
"jest-canvas-mock"
],
"setupTestFrameworkScriptFile": "<rootDir>/config/jest/config.ts",
"transform": {
"^.+\\.(ts|js|html)$": "ts-jest"
},
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!@ngrx|@agm)"
],
"globals": {
"ts-jest": {
"tsConfig": "tsconfig.spec.json",
"diagnostics": false,
"stringifyContentPathRegex": "\\.html$"
},
"window": true
},
Any idea what might be happening here?
Please have a look at jest-preset.js, especially astTransformers.
If ts-jest inside globals is defined, it will override the default global options, so other options as astTransformers have to be specified again.
I realized the configuration example in the README.md is not working, astTransformers is missing. We will have to update that soon, before it will lead to more confusion.
cc @thymikee @ahnpnl
Please confirm if this solves the issue, cheers!
@wtho interesting -- it works, but only if I add --no-cache every time. Thank you for your reply, at least it's working! I'm not totally sure what --no-cache actually does, is there a way to re-cache with the new transformer or something?
@mcblum you can run yarn run jest --clearCache first and then run normal test command. It will do the same as --no-cache but it clears cache for you once. The next time after your tests finish, it caches the correct configuration.
@ahnpnl thank you!!!
I do not have any globals in my setup, but facing the same issue. I am using Nrwl NX, not sure if they are using globals somewhere under the hood.
@mohyeid please check your jest-preset-angular-version in package.json and your jest configuration jest.config.js.
Adjust the configuration to the version you use. Make sure you picked the right release-branch when looking at the README of this repository.
The current github master branch contains breaking changes and a new configuration style, so if you do not use 7.0.0-alpha, you should look at the README in release/6. If you did an upgrade to 7.0.0-alpha, you have to adjust your nrwl-generated configuration.
@wtho Thanks. I debugged into the NX builder and found its overriding the globals. There is a ticket open to avoid that.
@mohyeid I have the same problem... did you figure it out? Do you maybe have a config snippet to share? nx doesn't play nice with this library