Seems ignore modules required using "require"
See original GitHub issueIssue :
ts-jest don’t transform modules required using require
.
/home/alejandro/Documentos/Proyectos/tattoo/server/src/resolvers/pictureResolver.ts:1
import { IResolverObject } from "apollo-server-express";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Module._compile (internal/modules/cjs/loader.js:892:18)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Function.resolvers (/home/alejandro/Documentos/Proyectos/tattoo/server/src/helpers/graphqlHelper.ts:20:28)
at new GraphqlMiddleware (/home/alejandro/Documentos/Proyectos/tattoo/server/src/middlewares/graphqlMiddleware.ts:12:48)
at new <anonymous> (/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/tsyringe/dist/cjs/decorators/auto-injectable.js:11:17)
at WebServer.initialize (/home/alejandro/Documentos/Proyectos/tattoo/server/src/webServer.ts:16:35)
at Object.start (/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/bootstrap.ts:12:21)
at async exports.default (/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts:5:5)
/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/shelljs/src/common.js:401
if (config.fatal) throw e;
^
Expected behavior :
Transform modules required using require
.
Debug log:
# content of ts-jest.log :
{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"24.1.0"},"message":"creating jest presets not handling JavaScript files","sequence":1,"time":"2019-11-01T12:44:10.300Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","version":"24.1.0"},"message":"creating Importer singleton","sequence":2,"time":"2019-11-01T12:44:10.521Z"}
{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"24.1.0"},"message":"creating jest presets not handling JavaScript files","sequence":3,"time":"2019-11-01T12:44:10.524Z"}
{"context":{"actualVersion":"24.9.0","expectedVersion":">=24 <25","logLevel":20,"namespace":"versions","package":"ts-jest","version":"24.1.0"},"message":"checking version of jest: OK","sequence":4,"time":"2019-11-01T12:44:10.526Z"}
{"context":{"baseOptions":{},"logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformerId":1,"version":"24.1.0"},"message":"created new transformer","sequence":5,"time":"2019-11-01T12:44:10.526Z"}
{"context":{"fileName":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/tmp/jest_rs","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/home/alejandro/Documentos/Proyectos/tattoo/server","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","globalTeardown":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/teardown.ts","globals":{},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"f6f089f16ba1aae0dd1bce75243f1d62","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server","roots":["/home/alejandro/Documentos/Proyectos/tattoo/server"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/home/alejandro/Documentos/Proyectos/tattoo/server/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":"/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"instrument":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server"},"transformerId":1,"version":"24.1.0"},"message":"computing cache key for /home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","sequence":6,"time":"2019-11-01T12:44:10.528Z"}
{"context":{"logLevel":30,"namespace":"jest-transformer","package":"ts-jest","transformerId":1,"version":"24.1.0"},"message":"no matching config-set found, creating a new one","sequence":7,"time":"2019-11-01T12:44:10.528Z"}
{"context":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/tmp/jest_rs","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/home/alejandro/Documentos/Proyectos/tattoo/server","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","globalTeardown":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/teardown.ts","globals":{},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"f6f089f16ba1aae0dd1bce75243f1d62","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server","roots":["/home/alejandro/Documentos/Proyectos/tattoo/server"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/home/alejandro/Documentos/Proyectos/tattoo/server/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":"/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"logLevel":20,"namespace":"backports","package":"ts-jest","transformerId":1,"version":"24.1.0"},"message":"backporting config","sequence":8,"time":"2019-11-01T12:44:10.529Z"}
{"context":{"jestConfig":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/tmp/jest_rs","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/home/alejandro/Documentos/Proyectos/tattoo/server","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","globalTeardown":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/teardown.ts","globals":{"ts-jest":{}},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"f6f089f16ba1aae0dd1bce75243f1d62","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server","roots":["/home/alejandro/Documentos/Proyectos/tattoo/server"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/home/alejandro/Documentos/Proyectos/tattoo/server/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":"/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"version":"24.1.0"},"message":"normalized jest config","sequence":9,"time":"2019-11-01T12:44:10.529Z"}
{"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.1.0"},"message":"normalized ts-jest config","sequence":10,"time":"2019-11-01T12:44:10.529Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"version":"24.1.0"},"message":"babel is disabled","sequence":11,"time":"2019-11-01T12:44:10.534Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","requireResult":{"exists":true,"given":"typescript","path":"/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/typescript/lib/typescript.js"},"version":"24.1.0"},"message":"loaded module typescript","sequence":12,"time":"2019-11-01T12:44:10.654Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","version":"24.1.0"},"message":"patching typescript","sequence":13,"time":"2019-11-01T12:44:10.654Z"}
{"context":{"actualVersion":"3.6.3","expectedVersion":">=2.7 <4","logLevel":20,"namespace":"versions","package":"ts-jest","version":"24.1.0"},"message":"checking version of typescript: OK","sequence":14,"time":"2019-11-01T12:44:10.655Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"tsConfigFileName":"/home/alejandro/Documentos/Proyectos/tattoo/server/tsconfig.json","version":"24.1.0"},"message":"readTsConfig(): reading /home/alejandro/Documentos/Proyectos/tattoo/server/tsconfig.json","sequence":15,"time":"2019-11-01T12:44:10.655Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"tsconfig":{"input":{"compilerOptions":{"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"importHelpers":true,"lib":["es2019"],"module":"commonjs","moduleResolution":"node","noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./dist/","strict":true,"target":"es2019"}},"resolved":{"compileOnSave":false,"configFileSpecs":{"excludeSpecs":["./dist/"],"includeSpecs":["**/*"],"validatedExcludeSpecs":["./dist/"],"validatedIncludeSpecs":["**/*"],"wildcardDirectories":{"/home/alejandro/Documentos/Proyectos/tattoo/server":1}},"errors":[],"fileNames":["/home/alejandro/Documentos/Proyectos/tattoo/server/src/index.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/src/ormClient.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/src/webServer.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/src/entities/pictureEntity.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/src/helpers/graphqlHelper.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/src/middlewares/graphqlMiddleware.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/src/middlewares/ormMiddleware.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/src/providers/pictureProvider.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/src/resolvers/pictureResolver.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/src/stores/pictureStore.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/src/types/commonType.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/test/picture.spec.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/bootstrap.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/teardown.ts","/home/alejandro/Documentos/Proyectos/tattoo/server/test/utils/request.ts"],"options":{"configFilePath":"/home/alejandro/Documentos/Proyectos/tattoo/server/tsconfig.json","declaration":false,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"importHelpers":true,"inlineSourceMap":false,"inlineSources":true,"lib":["lib.es2019.d.ts"],"module":1,"moduleResolution":2,"noEmit":false,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"$$ts-jest$$","removeComments":false,"sourceMap":true,"strict":true,"target":6},"raw":{"compileOnSave":false,"compilerOptions":{"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"importHelpers":true,"lib":["es2019"],"module":"commonjs","moduleResolution":"node","noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./dist/","strict":true,"target":"es2019"}},"typeAcquisition":{"enable":false,"exclude":[],"include":[]},"wildcardDirectories":{"/home/alejandro/Documentos/Proyectos/tattoo/server":1}}},"version":"24.1.0"},"message":"normalized typescript config","sequence":16,"time":"2019-11-01T12:44:10.664Z"}
{"context":{"fileName":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/bootstrap.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/tmp/jest_rs","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/home/alejandro/Documentos/Proyectos/tattoo/server","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","globalTeardown":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/teardown.ts","globals":{},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"f6f089f16ba1aae0dd1bce75243f1d62","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server","roots":["/home/alejandro/Documentos/Proyectos/tattoo/server"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/home/alejandro/Documentos/Proyectos/tattoo/server/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":"/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"instrument":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server"},"transformerId":1,"version":"24.1.0"},"message":"computing cache key for /home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/bootstrap.ts","sequence":17,"time":"2019-11-01T12:44:10.668Z"}
{"context":{"fileName":"/home/alejandro/Documentos/Proyectos/tattoo/server/src/ormClient.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/tmp/jest_rs","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/home/alejandro/Documentos/Proyectos/tattoo/server","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","globalTeardown":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/teardown.ts","globals":{},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"f6f089f16ba1aae0dd1bce75243f1d62","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server","roots":["/home/alejandro/Documentos/Proyectos/tattoo/server"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/home/alejandro/Documentos/Proyectos/tattoo/server/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":"/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"instrument":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server"},"transformerId":1,"version":"24.1.0"},"message":"computing cache key for /home/alejandro/Documentos/Proyectos/tattoo/server/src/ormClient.ts","sequence":18,"time":"2019-11-01T12:44:10.673Z"}
{"context":{"fileName":"/home/alejandro/Documentos/Proyectos/tattoo/server/src/webServer.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/tmp/jest_rs","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/home/alejandro/Documentos/Proyectos/tattoo/server","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","globalTeardown":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/teardown.ts","globals":{},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"f6f089f16ba1aae0dd1bce75243f1d62","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server","roots":["/home/alejandro/Documentos/Proyectos/tattoo/server"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/home/alejandro/Documentos/Proyectos/tattoo/server/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":"/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"instrument":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server"},"transformerId":1,"version":"24.1.0"},"message":"computing cache key for /home/alejandro/Documentos/Proyectos/tattoo/server/src/webServer.ts","sequence":19,"time":"2019-11-01T12:44:10.865Z"}
{"context":{"fileName":"/home/alejandro/Documentos/Proyectos/tattoo/server/src/middlewares/graphqlMiddleware.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/tmp/jest_rs","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/home/alejandro/Documentos/Proyectos/tattoo/server","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","globalTeardown":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/teardown.ts","globals":{},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"f6f089f16ba1aae0dd1bce75243f1d62","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server","roots":["/home/alejandro/Documentos/Proyectos/tattoo/server"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/home/alejandro/Documentos/Proyectos/tattoo/server/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":"/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"instrument":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server"},"transformerId":1,"version":"24.1.0"},"message":"computing cache key for /home/alejandro/Documentos/Proyectos/tattoo/server/src/middlewares/graphqlMiddleware.ts","sequence":20,"time":"2019-11-01T12:44:10.917Z"}
{"context":{"fileName":"/home/alejandro/Documentos/Proyectos/tattoo/server/src/helpers/graphqlHelper.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/tmp/jest_rs","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/home/alejandro/Documentos/Proyectos/tattoo/server","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","globalTeardown":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/teardown.ts","globals":{},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"f6f089f16ba1aae0dd1bce75243f1d62","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server","roots":["/home/alejandro/Documentos/Proyectos/tattoo/server"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/home/alejandro/Documentos/Proyectos/tattoo/server/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":"/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"instrument":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server"},"transformerId":1,"version":"24.1.0"},"message":"computing cache key for /home/alejandro/Documentos/Proyectos/tattoo/server/src/helpers/graphqlHelper.ts","sequence":21,"time":"2019-11-01T12:44:11.043Z"}
{"context":{"fileName":"/home/alejandro/Documentos/Proyectos/tattoo/server/src/providers/pictureProvider.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/tmp/jest_rs","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/home/alejandro/Documentos/Proyectos/tattoo/server","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","globalTeardown":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/teardown.ts","globals":{},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"f6f089f16ba1aae0dd1bce75243f1d62","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server","roots":["/home/alejandro/Documentos/Proyectos/tattoo/server"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/home/alejandro/Documentos/Proyectos/tattoo/server/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":"/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"instrument":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server"},"transformerId":1,"version":"24.1.0"},"message":"computing cache key for /home/alejandro/Documentos/Proyectos/tattoo/server/src/providers/pictureProvider.ts","sequence":22,"time":"2019-11-01T12:44:11.044Z"}
{"context":{"fileName":"/home/alejandro/Documentos/Proyectos/tattoo/server/src/stores/pictureStore.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/tmp/jest_rs","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/home/alejandro/Documentos/Proyectos/tattoo/server","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","globalTeardown":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/teardown.ts","globals":{},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"f6f089f16ba1aae0dd1bce75243f1d62","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server","roots":["/home/alejandro/Documentos/Proyectos/tattoo/server"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/home/alejandro/Documentos/Proyectos/tattoo/server/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":"/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"instrument":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server"},"transformerId":1,"version":"24.1.0"},"message":"computing cache key for /home/alejandro/Documentos/Proyectos/tattoo/server/src/stores/pictureStore.ts","sequence":23,"time":"2019-11-01T12:44:11.046Z"}
{"context":{"fileName":"/home/alejandro/Documentos/Proyectos/tattoo/server/src/entities/pictureEntity.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/tmp/jest_rs","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/home/alejandro/Documentos/Proyectos/tattoo/server","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","globalTeardown":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/teardown.ts","globals":{},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"f6f089f16ba1aae0dd1bce75243f1d62","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server","roots":["/home/alejandro/Documentos/Proyectos/tattoo/server"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/home/alejandro/Documentos/Proyectos/tattoo/server/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":"/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"instrument":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server"},"transformerId":1,"version":"24.1.0"},"message":"computing cache key for /home/alejandro/Documentos/Proyectos/tattoo/server/src/entities/pictureEntity.ts","sequence":24,"time":"2019-11-01T12:44:11.046Z"}
{"context":{"fileName":"/home/alejandro/Documentos/Proyectos/tattoo/server/src/middlewares/ormMiddleware.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/tmp/jest_rs","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/home/alejandro/Documentos/Proyectos/tattoo/server","dependencyExtractor":null,"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globalSetup":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/setup.ts","globalTeardown":"/home/alejandro/Documentos/Proyectos/tattoo/server/test/globals/teardown.ts","globals":{},"haste":{"computeSha1":false,"providesModuleNodeModules":[],"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"f6f089f16ba1aae0dd1bce75243f1d62","prettierPath":"prettier","resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server","roots":["/home/alejandro/Documentos/Proyectos/tattoo/server"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/home/alejandro/Documentos/Proyectos/tattoo/server/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":"/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/home/alejandro/Documentos/Proyectos/tattoo/server/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"instrument":false,"rootDir":"/home/alejandro/Documentos/Proyectos/tattoo/server"},"transformerId":1,"version":"24.1.0"},"message":"computing cache key for /home/alejandro/Documentos/Proyectos/tattoo/server/src/middlewares/ormMiddleware.ts","sequence":25,"time":"2019-11-01T12:44:11.051Z"}
Minimal repo :
jest.config.js:
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
globalSetup: './test/globals/setup.ts',
globalTeardown: './test/globals/teardown.ts',
};
tsconfig.json:
{
"compilerOptions": {
"target": "es2019",
"module": "commonjs",
"lib": [
"es2019"
],
"outDir": "./dist/",
"importHelpers": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}
src/helpers/graphqlHelper.ts:
import { IResolvers } from "apollo-server-express";
import { sync } from "globby";
import { join } from "path";
export default abstract class GraphqlHelper {
public static resolvers(directory: string): IResolvers[] {
const files = sync(join(directory, "*.{js,ts}"));
const resolvers = [];
for (const file of files) {
resolvers.push(require(file).default); //HERE FAIL WHEN REQUIRING THE NEXT MODULE
}
return resolvers;
}
}
src/resolvers/pictureResolver.ts:
import { IResolverObject } from "apollo-server-express";
import { ResolverContext } from "../types/commonType";
export default {
Query: typeQuery(),
};
function typeQuery(): IResolverObject<undefined, ResolverContext> {
return {
pictureAll: async (...[, { limit, offset }, { dataSources }]) => {
return dataSources.pictureProvider.getAll(limit, offset);
},
};
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:10
Top Results From Across the Web
Requiring modules in Node.js: Everything you need to know
Node uses two core modules for managing module dependencies: The require module, which appears to be available on the global scope — no...
Read more >RequireJS: Set path to 'ignore' - javascript - Stack Overflow
This will define the module in such a way that if it is required somewhere, its value will be undefined . Share.
Read more >global-require - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >@rollup/plugin-commonjs - npm
Rollup with @rollup/plugin-node-resolve resolves modules to their real paths by default. So include and exclude paths should handle real paths ...
Read more >Modules: Packages | Node.js v19.3.0 Documentation
It can load JSON modules, but an import assertion is required. ... and "default" conditions implemented in Node.js core are ignored by default....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Been stuck for more than 5 hours with the same issue. Same scenario, tried everything, no idea what it is. Decided to not update Jest/TS-Jest/TypeScript for now.
EDIT: It seems that the transformer is not working for TypeScript files required by the globalSetup script. By dissecting code, found out that Jest’s 24.9.0 release broke this behavior, and https://github.com/facebook/jest/pull/8756 is the only relevant change that would cause this issue.
Jest 27 is out 🎉 🎉
@ahnpnl worth reopening the issue?