Skip to content
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

doc: add troubleshooting section about extremely long load times #4567

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,40 @@ module.exports = {
**some-module** and **another-module** will be transformed.

For more information see [here](https://stackoverflow.com/questions/63389757/jest-unit-test-syntaxerror-cannot-use-import-statement-outside-a-module) and [here](https://stackoverflow.com/questions/52035066/how-to-write-jest-transformignorepatterns).


## Tests gets stuck when loading a dependency

### PROBLEM

Without cache, jest takes an extremely long time to process files and appears to be stuck.

### SOLUTION

`ts-jest` internally uses TypeScript compiler API to transform ts/js file into js file. The recommendation is to only transform what is needed.

A possible cause for that issue is that you may have enabled `ts-jest` to process javascript files in addition to TypeScript files. This leads to the result that more files are loaded which can, in some cases, blow up the machine.

- In your tsconfig file, check if `compilerOptions.allowJs` is unset or set to false.

```javascript
{
"compilerOptions": {
"allowJs": false,
}
}
```

- In your jest configuration, check if the transform property includes only `.ts` files for ts-jest. If not, change the regular expression to exclude js files. You can also add the attribute `isolatedModules: true` for ts-jest to disable type checking for tests.

```diff
module.exports = {
...
'transform': {
- '^.+\\.(t|j)s$': ['ts-jest', {}],
+ '^.+\\.ts$': ['ts-jest', { isolatedModules: true }],
},
};
```

For more information see [here](https://github.com/kulshekhar/ts-jest/issues/4294)
Loading