Minimal installation of Jest + TypeScript does not work. See demo repo, but in short: simply using the the config in package.json as described in README.md, I get the following error:
> [email protected] test /Users/Ian/Code/ianpaschal/ts-jest-error
> jest
FAIL tests/Demo.test.ts
● Test suite failed to run
ReferenceError: [ts-jest] Unable to find TS configuration file given current configuration
at Object.getTSConfig_local (node_modules/ts-jest/src/utils/get-ts-config.ts:30:11)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 2.094s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: `jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Ian/.npm/_logs/2018-08-26T21_56_57_541Z-debug.log
This can be alleviated by adding a tsconfig.json but this is not required for TypeScript and many users should not have it. IMO this bug can be solved by implementing the same "sane defaults" that TypeScript uses sans-config, or by adding it to the usage instructions: "MAKE SURE YOU HAVE A TSCONFIG FILE!!!11one"
My tests run and I see some output.
# content of debug.txt :
^Nothing created in that directory even with debug set to true. Are those instructions still up to date?
https://github.com/ianpaschal/ts-jest-error
Minimal repo above. Will keep it open for now but in case I remove it, it's just an empty repo with the following package.json which is npm install'd.
{
"name": "ts-jest-error",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
},
"author": "",
"license": "MIT",
"devDependencies": {
"@types/jest": "^23.3.1",
"jest": "^23.5.0",
"ts-jest": "^23.1.4",
"typescript": "^3.0.1"
},
"jest": {
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/tests/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
}
Everything else empty.
Thanks!
Stared at the problem for too long and didn't see the obvious: I never made a tsconfig.json file since I didn't need it for plain TS or bundling with Parcel.
I would put that somewhere in README.md since it's not necessarily a required thing to have in an existing TS project, but apparently required by ts-jest.
Hi @ianpaschal, thanks for reporting this issue.
You'll need to create a tsconfig.json file in the root of your project for ts-jest to work.
Answered at the same time, sorry... I guess it used to be a mandatory thing for TypeScript to work but apparently it's not anymore.
I suppose it's an issue anyway, ts-jest should be working without any tsconfig as TypeScript does.
I suppose it's an issue anyway, ts-jest should be working without any tsconfig as TypeScript does.
Maybe you're right. I'll re-open it and reformat it.
Made a PR with a proposed fix because I imagine this is fairly low priority for you guys and because "Yay! Participation! 🎉"
Most helpful comment
Made a PR with a proposed fix because I imagine this is fairly low priority for you guys and because "Yay! Participation! 🎉"