Similar but not the same as #950.
Running tests on my TypeScript project, including a TypeScript dependency, succeeds on Windows. It fails on Linux and OSX with the following:
FAIL src/__tests__/storyshots.test.ts
● Test suite failed to run
TypeError: Unable to require `.d.ts` file.
This is usually the result of a faulty configuration or import. Make sure there is a `.js`, `.json` or another executable extension available alongside `Fields.ts`.
at getOutput (../node_modules/ts-jest/dist/compiler.js:163:23)
at Object.compile (../node_modules/ts-jest/dist/compiler.js:185:29)
at TsJestTransformer.process (../node_modules/ts-jest/dist/ts-jest-transformer.js:101:41)
at Object.<anonymous> (../node_modules/@adm/webpart-library/src/Types.ts:1:1)
Fields.ts contains:
All of which are exported.
Here is my jest.config.json:
{
"preset": "@voitanos/jest-preset-spfx-react16",
"rootDir": "../src",
"reporters": ["default", "jest-junit"],
"coverageReporters": ["cobertura", "html"],
"collectCoverageFrom": ["**/*.{js,jsx,ts,tsx}", "!**/node_modules/**"],
"moduleNameMapper": {
"\\.(css|scss)$": "identity-obj-proxy",
"^resx-strings/en-us.json": "<rootDir>/node_modules/@microsoft/sp-core-library/lib/resx-strings/en-us.json",
"^office-ui-fabric-react/lib/(.*)$": "office-ui-fabric-react/lib-commonjs/$1",
"^@adm/(.*)/lib/(.*)$": "@adm/$1/src/$2",
"^@adm\/([^\/]*)$": "@adm/$1/src",
"telemetry": "identity-obj-proxy",
"PeopleSearchService": "identity-obj-proxy"
},
"transformIgnorePatterns": [
"node_modules/(?!@adm/)"
]
}
The test succeeds regardless of operating system.
Very sorry but I do not have time to set one of these up right now. I will try and find the time to get a repo set up as soon as I can.
I am using TS 3.5, NodeJS 8.10.0/10.16.x (tried both), Jest 24.9 and ts-jest 24.0.2.
confronted with the same issue.
@JakeStanger @Shigma - if you haven't fixed / worked around this, setting tsconfig.json/compilerOptions.preserveSymlinks to true fixes for me. (For me it's a repo using lerna, but seems like ts-node + symlinks are the issue, so any npm link type stuff in general)
Not using lerna or any other package/approach that should be creating symlinks, and this fix does not work for me. I will try and put together a minimal repo at some point soon but I still haven't found the cause exactly...
Had this issue too, downgraded jest to 24.8 and it fixes it. There is another issue in the list that has the 24.9 breaking change for this module
tsconfig.json/compilerOptions.preserveSymlinks fixed for me (I use Mac). Need some helps from community to investigate the solution.
I had the same issue, in a monorepo managed by yarn workspaces (without lerna), only on CI (Travis CI which uses Ubuntu, no issue on macOS).
Adding preserveSymlinks in each tsconfig.json solved the issue.
Downgrading Jest does not work for me, neither does preserveSymlinks. I am still no closer to finding the actual cause of the problem.
I am wondering if the new TS 3.8 export type feature will serve as a fix.
I have this issue as well :confused:
Same issue
Does anyone have a workaround? tsconfig.json/compilerOptions.preserveSymlinks did not fix it for me.
I'm on Linux, and it seems to occasionally work, but it consistently fails when I'm trying to run my tests on a gitlab ci.
I hit this on Windows, I have symlinks created manually.
PR #1385 solved something related and it was merged into master. However we are not sure that it will solve this issue. Can anyone please test the latest changes on master against this issue ?
Hi everyone, have you guys tested 25.2.1 for this issue ? Is this issue fixed for you guys ?
@ahnpnl in my case it worked! Thank you!
@ahnpnl working now for me as well.
Thanks,
This for me is causing another bizarre error...
With [email protected], and Jest 24.9.0 or 25.1.0, ALL tests now throw this:
● Test suite failed to run
TypeError: build_1.replaceRootDirInPath is not a function
at ../node_modules/ts-jest/dist/compiler.js:117:54
at Array.map (<anonymous>)
at Object.createCompiler (../node_modules/ts-jest/dist/compiler.js:117:14)
at ConfigSet.get (../node_modules/ts-jest/dist/config/config-set.js:389:31)
at ConfigSet.tsCompiler (../node_modules/ts-jest/dist/util/memoize.js:43:24)
at TsJestTransformer.process (../node_modules/ts-jest/dist/ts-jest-transformer.js:101:30)
at ScriptTransformer.transformSource (../node_modules/@jest/transform/build/ScriptTransformer.js:444:35)
at ScriptTransformer._transformAndBuildScript (../node_modules/@jest/transform/build/ScriptTransformer.js:522:40)
at ScriptTransformer.transform (../node_modules/@jest/transform/build/ScriptTransformer.js:560:25)
probably caused by jest-config isn't there, which is fixed in #1408
Excellent, installing jest-config seems to have fixed it. The new ts-jest version has also fixed the original issue. Awesome!
I'll close this issue now, thank you everybody.
Most helpful comment
PR #1385 solved something related and it was merged into master. However we are not sure that it will solve this issue. Can anyone please test the latest changes on master against this issue ?