Transforming HTML errors out when using "ts-jest" as transform, instead of preprocessor
See original GitHub issueHere’s my jest.config.js:
module.exports = {
"verbose": true,
"preset": "jest-preset-angular",
"globals": {
"ts-jest": {
"tsConfigFile": "client/tsconfig.spec.json",
"skipBabel": true
},
"\_\_TRANSFORM_HTML\_\_": true
},
"transform": {
"^.+\\.(ts|js|html)$": "<rootDir>/node_modules/jest-preset-angular/preprocessor.js"
},
"cacheDirectory": "./.jest-cache",
"testURL": "http://localstorage:8080",
"testMatch": [
"**/+(*.)+(spec|test).+(ts|js)"
],
"testPathIgnorePatterns": [
"/node_modules/",
"/tests/integration/"
],
"moduleNameMapper": {
"app/(.*)": "<rootDir>/client/app/$1",
"store/(.*)": "<rootDir>/client/store/$1",
"services/(.*)": "<rootDir>/client/services/$1",
"models/(.*)": "<rootDir>/client/models/$1",
"common/models": "<rootDir>/common/models",
"shared/(.*)": "<rootDir>/client/app/shared/$1",
"test-helpers/(.*)": "<rootDir>/client/test-helpers/$1"
},
"modulePaths": [
"<rootDir>/client/"
],
"moduleFileExtensions": [
"ts",
"js",
"html"
],
"coverageReporters": [
"json",
"lcov"
],
"coverageDirectory": "coverage",
"setupFiles": [
"jest-localstorage-mock"
],
"setupTestFrameworkScriptFile": "<rootDir>/client/test-helpers/setupJest.ts"
};
This works fine, but throws a deprecation warning for the transform. If I switch the transform to:
"transform": { "^.+\\.(ts|js|html)$": "ts-jest" },
then I get errors on every component test:
This test module uses the component MyComponent which is using a “templateUrl” or “styleUrls”, but they were never compiled. Please call “TestBed.compileComponents” before your test.
What’s going on here?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Code Transformation - Jest
A transformer is a module that provides a method for transforming source files. For example, if you wanted to be able to use...
Read more >TypeError: Jest: a transform must export a `process` function
I have tried different configurations with the jest.config.js file but not able to resolve this error. Any pointers to resolve this issue would ......
Read more >jest-preset-angular - npm
This tells ts-jest (a preprocessor this preset using to transform TS files) to treat JS files the same as TS ones. Transpile js...
Read more >jest transform node_modules - You.com | The AI Search ...
This error shows that "react-native" has not been transformed: ... can't transform a folder inside node_modules with ts-jest.
Read more >babel-jest | Yarn - Package Manager
Jest plugin to use babel for transformation. ... are already using jest-cli , add babel-jest and it will automatically compile JavaScript code using...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ilancohen did you get this to work? I’m seeing the exact same errors where almost all tests are failing with:
jest-preset-angular can not be updated as the new version does not play nicely with https://github.com/nrwl/nx/issues/1059
So if you’re having issues it could be because of nrwl/nx