How to disable ts-jest process my .js files
See original GitHub issueIssue :
I place in jest.conf.js such code:
module.exports = {
....
testMatch: ['**/__tests__/**/*.spec.ts'],
transform: {
'^.+\\.ts$': 'ts-jest',
},
...
}
Expected behavior :
I want to disable ts-jest process my .js files. It found tests that is .spec.ts, but if test have an import from some package (.js), then ts-jest started to process that import.
How can I configure such behavior to disable ts-jest[jest-transformer] for imported modules inside tests?
I also tryed to do as warning told me. I tried to add allowJs: false
in my tsconfig - but has no effect.
How can I fix that on jest.conf.js
level?
Debug log:
I always see this in log and tests pass much slower than it was since there was jest/ts-jest23.
ts-jest[jest-transformer] (WARN) Got a `.js` file to compile while `allowJs` option is not set to `true` (file: ....js). To fix this:
- if you want TypeScript to process JS files, set `allowJs` to `true` in your TypeScript config (usually tsconfig.json)
- if you do not want TypeScript to process your `.js` files, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match `.js` files anymore
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Stop Jest from running tests on TS files and only on JS files
I can't get Jest, using the command npm test in my program to stop running tests on my TS files. I only want...
Read more >Diagnostics option | ts-jest - GitHub Pages
By default all diagnostics are enabled. This is the same as setting the diagnostics option to true . To disable all diagnostics, set...
Read more >Configuring Jest
To read TypeScript configuration files Jest requires ts-node . Make sure it is installed in your project. The configuration also can be stored ......
Read more >How to configure Jest with TypeScript | Swizec Teller
yarn add -D jest typescript ts-jest @types/jest ts-node ... jest.config.js ... add this to your package.json file or build process:.
Read more >Speed up TypeScript with Jest | miyauci.me
Stop to use jest.config.ts. The above result used jest.config.js as the jest config file. However, the .ts ...
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 FreeTop 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
Top GitHub Comments
solved by adding
transformIgnorePatterns: ['^.+\\.js$'],
in jest.config.jsUse
testMatch
insteadThe default in Jest 24 is
[ "**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)" ]
(docs)To disable JS files, use
[ "**/__tests__/**/*.ts?(x)", "**/?(*.)+(spec|test).ts?(x)" ]