-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
improve "preset not found" error message #6863
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6863 +/- ##
==========================================
+ Coverage 66.97% 66.98% +<.01%
==========================================
Files 250 250
Lines 10355 10358 +3
Branches 3 3
==========================================
+ Hits 6935 6938 +3
Misses 3419 3419
Partials 1 1
Continue to review full report at Codecov.
|
Mind rebasing? :) |
… doesn't have 'jest-preset.js' or 'jest-preset.json' files at the root
a239f83
to
c9b9478
Compare
I'm still having major issues trying to use the default preset $ cat ./node_modules/ts-jest/jest-preset.js
module.exports = require('./presets/default/jest-preset') My module.exports = {
preset: './node_modules/ts-jest/jest-preset.js',
testEnvironment: 'node'
}; Tried this before, generated as per module.exports = {
preset: 'ts-jest',
testEnvironment: 'node'
}; $ jest
Validation Error:
Preset ts-jest not found. But it is right there $ cat ./node_modules/ts-jest/presets/default/jest-preset.js
module.exports = require('..').defaults Note: Created my project via typescript-starter and tried to switch from My package dependencies "dependencies": {
"sha.js": "^2.4.11",
"@types/jest": "^23.3.9"
},
"devDependencies": {
"codecov": "^3.1.0",
"cz-conventional-changelog": "^2.1.0",
"gh-pages": "^2.0.0",
"npm-run-all": "^4.1.3",
"nyc": "^13.0.1",
"opn-cli": "^3.1.0",
"prettier": "^1.14.3",
"standard-version": "^4.4.0",
"trash-cli": "^1.4.0",
"ts-jest": "^23.10.5",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-immutable": "^4.7.0",
"typedoc": "^0.13.0",
"typescript": "^3.0.3"
},
Thanks |
Would be helpful if the error message also returned the absolute path of the require so as to make it a bit easier to debug. Thanks |
Finally got it working, using a hardcoded config. module.exports = {
"roots": [
"<rootDir>/src"
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
} |
It worked for me (at least using yarn). $ npx typescript-starter # chose hello as name, using yarn and a node project
$ cd hello
$ yarn add -D jest ts-jest @types/jest
$ yarn ts-jest config:init
$ yarn jest
Test Suites: 3 failed, 3 total
Tests: 0 total
Snapshots: 0 total
Time: 2.787s
Ran all test suites. Tests failed with either being unable to find @kristianmandrup can you provide a reproduction? |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
After the discussion on #6538
This PR adds a descriptive error message for a case when preset module exists but doesn't have
jest-preset.js
orjest-preset.json
files at the rootTest plan
Add a test case for it in
normalize.test.js