Comparing version
@@ -85,2 +85,3 @@ # Contributing | ||
$ npm ci | ||
$ npm run lint-prettier # Please format markdown files | ||
$ npm run start | ||
@@ -87,0 +88,0 @@ ``` |
@@ -6,9 +6,9 @@ export declare const LINE_FEED = "\n"; | ||
export declare const JS_JSX_REGEX: RegExp; | ||
export declare const TS_TRANSFORM_PATTERN = "^.+.tsx?$"; | ||
export declare const TS_TRANSFORM_PATTERN = "^.+\\.tsx?$"; | ||
export declare const ESM_TS_TRANSFORM_PATTERN = "^.+\\.m?tsx?$"; | ||
export declare const TS_JS_TRANSFORM_PATTERN = "^.+.[tj]sx?$"; | ||
export declare const TS_JS_TRANSFORM_PATTERN = "^.+\\.[tj]sx?$"; | ||
export declare const ESM_TS_JS_TRANSFORM_PATTERN = "^.+\\.m?[tj]sx?$"; | ||
export declare const JS_TRANSFORM_PATTERN = "^.+.jsx?$"; | ||
export declare const JS_TRANSFORM_PATTERN = "^.+\\.jsx?$"; | ||
export declare const ESM_JS_TRANSFORM_PATTERN = "^.+\\.m?jsx?$"; | ||
export declare const TS_EXT_TO_TREAT_AS_ESM: string[]; | ||
export declare const JS_EXT_TO_TREAT_AS_ESM: string[]; |
@@ -9,7 +9,7 @@ "use strict"; | ||
exports.JS_JSX_REGEX = /\.[cm]?jsx?$/; | ||
exports.TS_TRANSFORM_PATTERN = '^.+.tsx?$'; | ||
exports.TS_TRANSFORM_PATTERN = '^.+\\.tsx?$'; | ||
exports.ESM_TS_TRANSFORM_PATTERN = '^.+\\.m?tsx?$'; | ||
exports.TS_JS_TRANSFORM_PATTERN = '^.+.[tj]sx?$'; | ||
exports.TS_JS_TRANSFORM_PATTERN = '^.+\\.[tj]sx?$'; | ||
exports.ESM_TS_JS_TRANSFORM_PATTERN = '^.+\\.m?[tj]sx?$'; | ||
exports.JS_TRANSFORM_PATTERN = '^.+.jsx?$'; | ||
exports.JS_TRANSFORM_PATTERN = '^.+\\.jsx?$'; | ||
exports.ESM_JS_TRANSFORM_PATTERN = '^.+\\.m?jsx?$'; | ||
@@ -16,0 +16,0 @@ // `extensionsToTreatAsEsm` will throw error with `.mjs` |
MIT License | ||
Copyright (c) 2016-2018 | ||
Copyright (c) 2016-2025 | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
{ | ||
"name": "ts-jest", | ||
"version": "29.2.5", | ||
"version": "29.2.6", | ||
"main": "dist/index.js", | ||
@@ -20,3 +20,3 @@ "types": "dist/index.d.ts", | ||
"lint-fix": "eslint --fix --ext .js,.ts .", | ||
"lint-prettier": "prettier '**/*.{yml,yaml,md}' --write", | ||
"lint-prettier": "prettier \"**/*.{yml,yaml,md}\" --write", | ||
"lint-prettier-ci": "prettier '**/*.{yml,yaml,md}' --check", | ||
@@ -63,3 +63,3 @@ "doc": "cd website && npm run start", | ||
"make-error": "^1.3.6", | ||
"semver": "^7.6.3", | ||
"semver": "^7.7.1", | ||
"yargs-parser": "^21.1.1" | ||
@@ -108,3 +108,3 @@ }, | ||
"@types/fs-extra": "^11.0.4", | ||
"@types/jest": "^29.5.12", | ||
"@types/jest": "^29.5.14", | ||
"@types/js-yaml": "^4.0.9", | ||
@@ -115,3 +115,3 @@ "@types/lodash.camelcase": "^4.3.9", | ||
"@types/micromatch": "^4.0.9", | ||
"@types/node": "20.16.1", | ||
"@types/node": "20.17.19", | ||
"@types/semver": "^7.5.8", | ||
@@ -124,7 +124,7 @@ "@types/yargs": "^17.0.33", | ||
"conventional-changelog-cli": "^5.0.0", | ||
"esbuild": "~0.21.5", | ||
"eslint": "^8.57.0", | ||
"esbuild": "~0.25.0", | ||
"eslint": "^8.57.1", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-jest": "^28.8.0", | ||
"eslint-plugin-import": "^2.31.0", | ||
"eslint-plugin-jest": "^28.11.0", | ||
"eslint-plugin-jsdoc": "^48.11.0", | ||
@@ -134,5 +134,5 @@ "eslint-plugin-prefer-arrow": "^1.2.3", | ||
"execa": "5.1.1", | ||
"fs-extra": "^11.2.0", | ||
"fs-extra": "^11.3.0", | ||
"glob": "^10.2.6", | ||
"glob-gitignore": "^1.0.14", | ||
"glob-gitignore": "^1.0.15", | ||
"husky": "~4.3.8", | ||
@@ -142,3 +142,3 @@ "jest": "^29.7.0", | ||
"json-schema-to-typescript": "^13.1.2", | ||
"lint-staged": "^15.2.9", | ||
"lint-staged": "^15.4.3", | ||
"prettier": "^2.8.8", | ||
@@ -145,0 +145,0 @@ "typescript": "~5.5.4" |
@@ -12,2 +12,3 @@ <h1 align="center">ts-jest</h1> | ||
<a href="https://github.com/kulshekhar/ts-jest/blob/main/LICENSE.md"><img src="https://img.shields.io/npm/l/ts-jest.svg?style=flat-square" alt="GitHub license"/> </a> | ||
<a href="https://gurubase.io/g/ts-jest"><img src="https://img.shields.io/badge/Gurubase-Ask%20ts--jest%20Guru-006BFF?style=flat-square" alt="Gurubase"/> </a> | ||
</p> | ||
@@ -14,0 +15,0 @@ |
# Troubleshooting | ||
## Running ts-jest on CI tools | ||
### PROBLEM | ||
Cannot find module "" from "" | ||
### SOLUTION | ||
- Check if `rootDir` is referenced correctly. If not add this on your existing jest configuration. | ||
```javascript | ||
module.exports = { | ||
... | ||
roots: ["<rootDir>"] | ||
} | ||
``` | ||
- Check if module directories are included on your jest configuration. If not add this on your existing jest configuration. | ||
```javascript | ||
module.exports = { | ||
... | ||
moduleDirectories: ["node_modules","<module-directory>"], | ||
modulePaths: ["<path-of-module>"], | ||
} | ||
``` | ||
- Check if module name is properly mapped and can be referenced by jest. If not, you can define moduleNameMapper for your jest configuration. | ||
```javascript | ||
module.exports = { | ||
... | ||
moduleNameMapper: { | ||
"<import-path>": "<rootDir>/<real-physical-path>", | ||
}, | ||
} | ||
``` | ||
- Check github folder names if its identical to you local folder names. Sometimes github never updates your folder names even if you rename it locally. If this happens rename your folders via github or use this command `git mv <source> <destination>` and commit changes. | ||
## Transform (node)-module explicitly | ||
### PROBLEM | ||
SyntaxError: Cannot use import statement outside a module | ||
### SOLUTION | ||
One of the node modules hasn't the correct syntax for Jests execution step. It needs to | ||
be transformed first. | ||
There is a good chance that the error message shows which module is affected: | ||
```shell | ||
SyntaxError: Cannot use import statement outside a module | ||
> 22 | import Component from "../../node_modules/some-module/lib"; | ||
| ^ | ||
``` | ||
In this case **some-module** is the problem and needs to be transformed. | ||
By adding the following line to the configuration file it will tell Jest which modules | ||
shouldnt be ignored during the transformation step: | ||
```javascript | ||
module.exports = { | ||
... | ||
transformIgnorePatterns: ["node_modules/(?!(some-module|another-module))"] | ||
}; | ||
``` | ||
**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). | ||
Troubleshooting guide have been moved to https://kulshekhar.github.io/ts-jest/docs/guides/troubleshooting |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
75
1.35%326458
-0.4%+ Added
- Removed
Updated