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

ts-jest using wrong typescript version with yarn workspaces/monorepo (repro) #1333

Closed
andreialecu opened this issue Dec 30, 2019 · 17 comments · Fixed by #1377
Closed

ts-jest using wrong typescript version with yarn workspaces/monorepo (repro) #1333

andreialecu opened this issue Dec 30, 2019 · 17 comments · Fixed by #1377

Comments

@andreialecu
Copy link
Contributor

Issue :

I'm running into a blocking issue with ts-jest using yarn workspaces. I have multiple packages that define various typescript versions, and ts-jest seems to use the wrong one, rather than the one pinned inside each package.json.

So for example, I'm using typescript 3.7 syntax in a package, but the main node_modules folder has typescript defined as version 3.5.3 instead, and ts-jest seems to use that one instead of the one in the target package's node_modules which would correctly be 3.7.3.

Expected behavior :

Should use the proper typescript version defined in the sub-package's package.json.

Debug log:

Notice how the log file also shows how it's getting typescript from the wrong location:

{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"24.2.0"},"message":"creating jest presets not handling JavaScript files","sequence":1,"time":"2019-12-30T14:29:48.673Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","version":"24.2.0"},"message":"creating Importer singleton","sequence":2,"time":"2019-12-30T14:29:49.717Z"}
{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"24.2.0"},"message":"creating jest presets not handling JavaScript files","sequence":3,"time":"2019-12-30T14:29:49.723Z"}
{"context":{"actualVersion":"24.9.0","expectedVersion":">=24 <25","logLevel":20,"namespace":"versions","package":"ts-jest","version":"24.2.0"},"message":"checking version of jest: OK","sequence":4,"time":"2019-12-30T14:29:49.727Z"}
{"context":{"baseOptions":{},"logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"created new transformer","sequence":5,"time":"2019-12-30T14:29:49.727Z"}
{"context":{"fileName":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"C:\\Users\\enc\\AppData\\Local\\Temp\\jest","clearMocks":false,"coveragePathIgnorePatterns":["\\\\node_modules\\\\"],"cwd":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":null,"globalTeardown":null,"globals":{},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules","src"],"moduleFileExtensions":["js","json","ts"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"8ec854457256d0a91d7c5adf543309f5","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":true,"rootDir":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test","roots":["S:\\Projects\\opensource\\tsjestrepro\\packages\\test"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\jest-environment-node\\build\\index.js","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":["**/__tests__/**/*.[jt]s?(x)","**/?(*.)+(spec|test).[tj]s?(x)"],"testPathIgnorePatterns":["\\\\node_modules\\\\"],"testRegex":[],"testRunner":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\jest-jasmine2\\build\\index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","S:\\Projects\\opensource\\tsjestrepro\\node_modules\\ts-jest\\dist\\index.js"]],"transformIgnorePatterns":["\\\\node_modules\\\\"],"watchPathIgnorePatterns":[]},"instrument":false,"rootDir":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test"},"transformerId":1,"version":"24.2.0"},"message":"computing cache key for S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","sequence":6,"time":"2019-12-30T14:29:49.728Z"}
{"context":{"logLevel":30,"namespace":"jest-transformer","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"no matching config-set found, creating a new one","sequence":7,"time":"2019-12-30T14:29:49.728Z"}
{"context":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"C:\\Users\\enc\\AppData\\Local\\Temp\\jest","clearMocks":false,"coveragePathIgnorePatterns":["\\\\node_modules\\\\"],"cwd":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":null,"globalTeardown":null,"globals":{},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules","src"],"moduleFileExtensions":["js","json","ts"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"8ec854457256d0a91d7c5adf543309f5","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":true,"rootDir":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test","roots":["S:\\Projects\\opensource\\tsjestrepro\\packages\\test"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\jest-environment-node\\build\\index.js","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":["**/__tests__/**/*.[jt]s?(x)","**/?(*.)+(spec|test).[tj]s?(x)"],"testPathIgnorePatterns":["\\\\node_modules\\\\"],"testRegex":[],"testRunner":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\jest-jasmine2\\build\\index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","S:\\Projects\\opensource\\tsjestrepro\\node_modules\\ts-jest\\dist\\index.js"]],"transformIgnorePatterns":["\\\\node_modules\\\\"],"watchPathIgnorePatterns":[]},"logLevel":20,"namespace":"backports","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"backporting config","sequence":8,"time":"2019-12-30T14:29:49.729Z"}
{"context":{"jestConfig":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"C:\\Users\\enc\\AppData\\Local\\Temp\\jest","clearMocks":false,"coveragePathIgnorePatterns":["\\\\node_modules\\\\"],"cwd":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":null,"globalTeardown":null,"globals":{"ts-jest":{}},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules","src"],"moduleFileExtensions":["js","json","ts"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"8ec854457256d0a91d7c5adf543309f5","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":true,"rootDir":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test","roots":["S:\\Projects\\opensource\\tsjestrepro\\packages\\test"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\jest-environment-node\\build\\index.js","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":["**/__tests__/**/*.[jt]s?(x)","**/?(*.)+(spec|test).[tj]s?(x)"],"testPathIgnorePatterns":["\\\\node_modules\\\\"],"testRegex":[],"testRunner":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\jest-jasmine2\\build\\index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","S:\\Projects\\opensource\\tsjestrepro\\node_modules\\ts-jest\\dist\\index.js"]],"transformIgnorePatterns":["\\\\node_modules\\\\"],"watchPathIgnorePatterns":[]},"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"normalized jest config","sequence":9,"time":"2019-12-30T14:29:49.729Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"tsJestConfig":{"compiler":"typescript","diagnostics":{"ignoreCodes":[6059,18002,18003],"pretty":true,"throws":true},"isolatedModules":false,"packageJson":{"kind":"file"},"transformers":[],"tsConfig":{"kind":"file"}},"version":"24.2.0"},"message":"normalized ts-jest config","sequence":10,"time":"2019-12-30T14:29:49.730Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"babel is disabled","sequence":11,"time":"2019-12-30T14:29:49.732Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","requireResult":{"exists":true,"given":"typescript","path":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\typescript.js"},"version":"24.2.0"},"message":"loaded module typescript","sequence":12,"time":"2019-12-30T14:29:49.874Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","version":"24.2.0"},"message":"patching typescript","sequence":13,"time":"2019-12-30T14:29:49.874Z"}
{"context":{"actualVersion":"3.5.3","expectedVersion":">=2.7 <4","logLevel":20,"namespace":"versions","package":"ts-jest","version":"24.2.0"},"message":"checking version of typescript: OK","sequence":14,"time":"2019-12-30T14:29:49.874Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"tsConfigFileName":"S:/Projects/opensource/tsjestrepro/packages/test/tsconfig.json","version":"24.2.0"},"message":"readTsConfig(): reading S:/Projects/opensource/tsjestrepro/packages/test/tsconfig.json","sequence":15,"time":"2019-12-30T14:29:49.874Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"tsconfig":{"input":{"compilerOptions":{"allowSyntheticDefaultImports":true,"baseUrl":"./src","declaration":true,"emitDecoratorMetadata":true,"experimentalDecorators":true,"module":"commonjs","outDir":"./dist","removeComments":true,"resolveJsonModule":true,"sourceMap":true,"target":"es2018"},"exclude":["node_modules","dist"]},"resolved":{"compileOnSave":false,"configFileSpecs":{"excludeSpecs":["node_modules","dist"],"includeSpecs":["**/*"],"validatedExcludeSpecs":["node_modules","dist"],"validatedIncludeSpecs":["**/*"],"wildcardDirectories":{"s:/projects/opensource/tsjestrepro/packages/test":1}},"errors":[],"fileNames":["S:/Projects/opensource/tsjestrepro/packages/test/src/some.test.spec.ts"],"options":{"allowSyntheticDefaultImports":true,"baseUrl":"S:/Projects/opensource/tsjestrepro/packages/test/src","configFilePath":"S:/Projects/opensource/tsjestrepro/packages/test/tsconfig.json","declaration":false,"emitDecoratorMetadata":true,"experimentalDecorators":true,"inlineSourceMap":false,"inlineSources":true,"module":1,"noEmit":false,"outDir":"$$ts-jest$$","removeComments":false,"resolveJsonModule":true,"sourceMap":true,"target":5},"raw":{"compileOnSave":false,"compilerOptions":{"allowSyntheticDefaultImports":true,"baseUrl":"./src","declaration":true,"emitDecoratorMetadata":true,"experimentalDecorators":true,"module":"commonjs","outDir":"./dist","removeComments":true,"resolveJsonModule":true,"sourceMap":true,"target":"es2018"},"exclude":["node_modules","dist"]},"typeAcquisition":{"enable":false,"exclude":[],"include":[]},"wildcardDirectories":{"s:/projects/opensource/tsjestrepro/packages/test":1}}},"version":"24.2.0"},"message":"normalized typescript config","sequence":16,"time":"2019-12-30T14:29:49.884Z"}
{"context":{"fileName":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"instrument":false},"transformerId":1,"version":"24.2.0"},"message":"processing S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","sequence":17,"time":"2019-12-30T14:29:49.885Z"}
{"context":{"logLevel":20,"namespace":"ts-compiler","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"creating typescript compiler (language service)","sequence":18,"time":"2019-12-30T14:29:49.886Z"}
{"context":{"cacheDirectory":"C:\\Users\\enc\\AppData\\Local\\Temp\\jest\\ts-jest\\56\\9270a35b69609340943d3cb89ab7aa11046ce2","logLevel":20,"namespace":"config","package":"ts-jest","version":"24.2.0"},"message":"will use file caching","sequence":19,"time":"2019-12-30T14:29:49.886Z"}
{"context":{"logLevel":20,"namespace":"ts-compiler","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"creating language service","sequence":20,"time":"2019-12-30T14:29:49.886Z"}
{"context":{"fileName":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","logLevel":20,"namespace":"ts-compiler","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readThrough(): cache miss","sequence":21,"time":"2019-12-30T14:29:49.888Z"}
{"context":{"fileName":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","logLevel":20,"namespace":"ts-compiler","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getOutput(): compiling using language service","sequence":22,"time":"2019-12-30T14:29:49.888Z"}
{"context":{"fileName":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","logLevel":20,"namespace":"ts-compiler","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"updateMemoryCache()","sequence":23,"time":"2019-12-30T14:29:49.888Z"}
{"context":{"cacheHit":true,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache hit","sequence":24,"time":"2019-12-30T14:29:49.888Z"}
{"context":{"cacheHit":true,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache hit","sequence":25,"time":"2019-12-30T14:29:49.888Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":26,"time":"2019-12-30T14:29:49.895Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":27,"time":"2019-12-30T14:29:49.896Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":28,"time":"2019-12-30T14:29:49.897Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":29,"time":"2019-12-30T14:29:49.897Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":30,"time":"2019-12-30T14:29:49.898Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":31,"time":"2019-12-30T14:29:49.899Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":32,"time":"2019-12-30T14:29:49.899Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":33,"time":"2019-12-30T14:29:49.900Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":34,"time":"2019-12-30T14:29:49.902Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":35,"time":"2019-12-30T14:29:49.902Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":36,"time":"2019-12-30T14:29:49.903Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":37,"time":"2019-12-30T14:29:49.904Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":38,"time":"2019-12-30T14:29:49.906Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":39,"time":"2019-12-30T14:29:49.908Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":40,"time":"2019-12-30T14:29:49.910Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":41,"time":"2019-12-30T14:29:49.911Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":42,"time":"2019-12-30T14:29:49.912Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":43,"time":"2019-12-30T14:29:49.913Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":44,"time":"2019-12-30T14:29:49.914Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":45,"time":"2019-12-30T14:29:49.917Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":46,"time":"2019-12-30T14:29:49.918Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":47,"time":"2019-12-30T14:29:49.919Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\@types\\babel__core\\index.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":48,"time":"2019-12-30T14:29:49.920Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":49,"time":"2019-12-30T14:29:49.948Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":50,"time":"2019-12-30T14:29:49.950Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":51,"time":"2019-12-30T14:29:49.952Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":52,"time":"2019-12-30T14:29:49.954Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":53,"time":"2019-12-30T14:29:49.955Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":54,"time":"2019-12-30T14:29:49.956Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":55,"time":"2019-12-30T14:29:49.957Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":56,"time":"2019-12-30T14:29:49.959Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\@types\\babel__generator\\index.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":57,"time":"2019-12-30T14:29:49.960Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\@babel\\types\\lib\\index.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":58,"time":"2019-12-30T14:29:49.964Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\@types\\babel__traverse\\index.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":59,"time":"2019-12-30T14:29:50.016Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\@types\\babel__template\\index.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":60,"time":"2019-12-30T14:29:50.055Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\@babel\\parser\\typings\\babel-parser.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":61,"time":"2019-12-30T14:29:50.058Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":62,"time":"2019-12-30T14:29:50.060Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\@types\\istanbul-lib-coverage\\index.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":63,"time":"2019-12-30T14:29:50.061Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\@types\\istanbul-lib-report\\index.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":64,"time":"2019-12-30T14:29:50.062Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":65,"time":"2019-12-30T14:29:50.063Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":66,"time":"2019-12-30T14:29:50.064Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\@types\\istanbul-reports\\index.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":67,"time":"2019-12-30T14:29:50.065Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":68,"time":"2019-12-30T14:29:50.066Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":69,"time":"2019-12-30T14:29:50.067Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\@types\\jest\\index.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":70,"time":"2019-12-30T14:29:50.068Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":71,"time":"2019-12-30T14:29:50.108Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\jest-diff\\build\\index.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":72,"time":"2019-12-30T14:29:50.110Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":73,"time":"2019-12-30T14:29:50.112Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\jest-diff\\build\\types.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":74,"time":"2019-12-30T14:29:50.112Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":75,"time":"2019-12-30T14:29:50.113Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\@types\\stack-utils\\index.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":76,"time":"2019-12-30T14:29:50.114Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\@types\\yargs\\index.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":77,"time":"2019-12-30T14:29:50.115Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":78,"time":"2019-12-30T14:29:50.130Z"}
{"context":{"call":null,"logLevel":10,"namespace":"ts:serviceHost","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"readFile","sequence":79,"time":"2019-12-30T14:29:50.132Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\@types\\yargs-parser\\index.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":80,"time":"2019-12-30T14:29:50.132Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2018.full.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":81,"time":"2019-12-30T14:29:50.133Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2018.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":82,"time":"2019-12-30T14:29:50.134Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2017.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":83,"time":"2019-12-30T14:29:50.134Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2016.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":84,"time":"2019-12-30T14:29:50.135Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2015.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":85,"time":"2019-12-30T14:29:50.135Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es5.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":86,"time":"2019-12-30T14:29:50.135Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2015.core.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":87,"time":"2019-12-30T14:29:50.194Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2015.collection.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":88,"time":"2019-12-30T14:29:50.201Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2015.generator.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":89,"time":"2019-12-30T14:29:50.202Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2015.promise.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":90,"time":"2019-12-30T14:29:50.204Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2015.iterable.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":91,"time":"2019-12-30T14:29:50.213Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2015.symbol.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":92,"time":"2019-12-30T14:29:50.219Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2015.proxy.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":93,"time":"2019-12-30T14:29:50.220Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2015.reflect.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":94,"time":"2019-12-30T14:29:50.221Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2015.symbol.wellknown.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":95,"time":"2019-12-30T14:29:50.221Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2016.array.include.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":96,"time":"2019-12-30T14:29:50.223Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2017.object.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":97,"time":"2019-12-30T14:29:50.224Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2017.sharedmemory.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":98,"time":"2019-12-30T14:29:50.225Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2017.string.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":99,"time":"2019-12-30T14:29:50.225Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2017.intl.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":100,"time":"2019-12-30T14:29:50.226Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2017.typedarrays.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":101,"time":"2019-12-30T14:29:50.226Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2018.asynciterable.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":102,"time":"2019-12-30T14:29:50.228Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2018.promise.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":103,"time":"2019-12-30T14:29:50.229Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2018.regexp.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":104,"time":"2019-12-30T14:29:50.229Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.es2018.intl.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":105,"time":"2019-12-30T14:29:50.230Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.dom.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":106,"time":"2019-12-30T14:29:50.231Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.webworker.importscripts.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":107,"time":"2019-12-30T14:29:50.356Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.scripthost.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":108,"time":"2019-12-30T14:29:50.356Z"}
{"context":{"cacheHit":false,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\node_modules\\typescript\\lib\\lib.dom.iterable.d.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache miss","sequence":109,"time":"2019-12-30T14:29:50.358Z"}
{"context":{"call":null,"logLevel":20,"namespace":"ts-hoisting","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"visitSourceFileNode(): hoisting","sequence":110,"time":"2019-12-30T14:29:50.644Z"}
{"context":{"fileName":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","logLevel":20,"namespace":"ts-compiler","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getOutput(): computing diagnostics","sequence":111,"time":"2019-12-30T14:29:50.657Z"}
{"context":{"cacheHit":true,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache hit","sequence":112,"time":"2019-12-30T14:29:50.658Z"}
{"context":{"cacheHit":true,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache hit","sequence":113,"time":"2019-12-30T14:29:50.658Z"}
{"context":{"cacheHit":true,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache hit","sequence":114,"time":"2019-12-30T14:29:50.658Z"}
{"context":{"cacheHit":true,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache hit","sequence":115,"time":"2019-12-30T14:29:50.658Z"}
{"context":{"cacheHit":true,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache hit","sequence":116,"time":"2019-12-30T14:29:50.658Z"}
{"context":{"cacheHit":true,"logLevel":10,"namespace":"ts-compiler","normalizedFileName":"S:\\Projects\\opensource\\tsjestrepro\\packages\\test\\src\\some.test.spec.ts","package":"ts-jest","transformerId":1,"version":"24.2.0"},"message":"getScriptSnapshot(): cache hit","sequence":117,"time":"2019-12-30T14:29:50.658Z"}
{"context":{"diagnosticCodes":[1109,1109,1005],"diagnosticText":"\u001b[96msrc/some.test.spec.ts\u001b[0m:\u001b[93m4\u001b[0m:\u001b[93m15\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS1109: \u001b[0mExpression expected.\n\n\u001b[7m4\u001b[0m     expect(hi?.test?.hello);\n\u001b[7m \u001b[0m \u001b[91m              ~\u001b[0m\n\u001b[96msrc/some.test.spec.ts\u001b[0m:\u001b[93m4\u001b[0m:\u001b[93m21\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS1109: \u001b[0mExpression expected.\n\n\u001b[7m4\u001b[0m     expect(hi?.test?.hello);\n\u001b[7m \u001b[0m \u001b[91m                    ~\u001b[0m\n\u001b[96msrc/some.test.spec.ts\u001b[0m:\u001b[93m4\u001b[0m:\u001b[93m27\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS1005: \u001b[0m':' expected.\n\n\u001b[7m4\u001b[0m     expect(hi?.test?.hello);\n\u001b[7m \u001b[0m \u001b[91m                          ~\u001b[0m\n","logLevel":20,"namespace":"TSError","package":"ts-jest","version":"24.2.0"},"message":"created new TSError","sequence":118,"time":"2019-12-30T14:29:50.660Z"}

Minimal repo :

Repro at: https://github.com/andreialecu/tsjestrepro

@andreialecu
Copy link
Contributor Author

In a monorepo, yarn installs typescript with its different versions like this:

image

ts-jest should use the typescript package from the innermost package.

In the mean time, are there any workarounds to get unblocked?

@andreialecu
Copy link
Contributor Author

Found a workaround:

{
  "private": true,
  "workspaces": {
    "packages": ["packages/*"],
    "nohoist": ["**/ts-jest", "**/ts-jest/**"]
  },
  "scripts": {
    "test": "yarn workspace test test"
  }
}

Adding the nohoist option to ts-jest seems to work around this for now. More info might be available at: https://yarnpkg.com/blog/2018/02/15/nohoist/

@ahnpnl
Copy link
Collaborator

ahnpnl commented Jan 12, 2020

I agree at the moment ts-jest doesn’t support monorepo. However we are lack of experience with that so we need community help to implement it.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Jan 12, 2020

close in favor of #1343

@ahnpnl ahnpnl closed this as completed Jan 12, 2020
@ahnpnl
Copy link
Collaborator

ahnpnl commented Feb 7, 2020

hi @andreialecu , I checked your repo and I don't get what do you expect ? Do you expect the test in your test folder failed ? Can you elaborate more ?

@andreialecu
Copy link
Contributor Author

@ahnpnl If you clone the repo and run yarn then yarn test it will fail because the code uses syntax that is only valid with typescript 3.7 but ts-jest will find typescript 3.5 instead. If you look in packages/test/package.json, typescript is set to version 3.7 so this shouldn't happen.

It's possible the bug is in jest itself, in the way it loads ts-jest. I believe the proper way of dynamically importing modules is using https://nodejs.org/api/modules.html#modules_module_createrequire_filename or a polyfill of it instead of require.resolve.

@andreialecu
Copy link
Contributor Author

@ahnpnl
Copy link
Collaborator

ahnpnl commented Feb 7, 2020

I did these followings:

  • clone your repo
  • run yarn to install dependencies
  • I upgraded jest, ts-jest and @types/jest to v25
  • ran yarn test and i got error
    image

Is it what you expected ?

@andreialecu
Copy link
Contributor Author

andreialecu commented Feb 7, 2020

Yes, that's the error, I explained in the comment above why that shouldn't happen.

You can update the root package json to this:

{
  "private": true,
  "workspaces": {
    "packages": ["packages/*"],
    "nohoist": ["**/ts-jest", "**/ts-jest/**"]
  },
  "scripts": {
    "test": "yarn workspace test test"
  }
}

Run yarn --force again, then yarn test and it will pass. This shouldn't be needed though...

@ahnpnl
Copy link
Collaborator

ahnpnl commented Feb 7, 2020

ok I got it now, so the error shouldn't happen because the test folder has typescript 3.7.5 ?

@andreialecu
Copy link
Contributor Author

@ahnpnl yes.

Maybe @arcanis can provide some insight.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Feb 7, 2020

i like the solution using module.createRequire for node 12, module.createRequireFromPath for node 10 and polyfill for node 8. If you don't mind, please create a PR to help us 👍

@andreialecu
Copy link
Contributor Author

@ahnpnl I looked briefly through the code and I see that typescript is just imported normally, not through require.resolve.

Based on that, I suspect it's jest itself that uses some sort of require.resolve logic to find ts-jest and import it. Which then trickles down into ts-jest and typescript.

Unfortunately I'm not familiar with jest internals so I'm not sure where to look, but it might be in the code it uses to instantiate plugins.

It's possible for example that this fixes it: jestjs/jest#9520

@ahnpnl
Copy link
Collaborator

ahnpnl commented Feb 7, 2020

hmm i think it might be ts-jest issue as typescript is imported here which triggers require.resolve in importer

Tbh, I'm not sure the expected behavior is the correct behavior. In your repo, typescript on root level is installed with v3.5.3. If you run tsc on root level, tsc will be triggered by root typescript package and then node will be triggered to run the compiled js codes. It is the expected behavior.

If you want to run specific a typescript version, you have to tell typescript 1st by running tsc inside the folder which contains a different version of typescript. It would say this is general typescript module resolution.

@andreialecu
Copy link
Contributor Author

andreialecu commented Feb 7, 2020

Workspace packages are supposed to be isolated. Dependencies are only hoisted for optimization purposes, so they do not get duplicated.

Running yarn test is just an alias for yarn workspace <test> test. In retrospect, naming the directory test wasn't the best idea because it makes it confusing if you're not familiar with yarn workspaces.

Basically it runs the jest command inside the test package. This should not use the typescript of the root, that's a violation of boundaries.

But I think you identified where the problem is. That require.resolve line is the problem. I'll look into it as well and maybe I can send a PR.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Feb 7, 2020

Thanks 🙏

@andreialecu
Copy link
Contributor Author

andreialecu commented Feb 7, 2020

@ahnpnl I've opened a PR at #1377 which fixes it but I'm not sure if it adds any unwanted side-effects. I think tests still pass properly, but someone more familiar with ts-jest might need to review and test. Moving discussion to #1377

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants