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

Seems ignore modules required using "require" #1274

Closed
ghost opened this issue Nov 1, 2019 · 10 comments
Closed

Seems ignore modules required using "require" #1274

ghost opened this issue Nov 1, 2019 · 10 comments

Comments

@ghost
Copy link

ghost commented Nov 1, 2019

Issue :

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:

log file content
# 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);
        },
    };
}
@ChrisLahaye
Copy link

Did you solve this issue?

@ghost
Copy link
Author

ghost commented Nov 25, 2019

No, I could not solve it.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Jan 8, 2020

hi @localnet , may I have the full link to clone/download your minimum repo ?

@ghost
Copy link
Author

ghost commented Jan 9, 2020

Hi @ahnpnl, I am trying to reproduce it at current project, very similar, and all work well. I guess it was fixed at some new ts-jest version. So I will to close the issue, and if it happen again I will reopen it.

Thanks you.

@ghost ghost closed this as completed Jan 9, 2020
@dgadelha
Copy link

dgadelha commented Feb 6, 2020

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 jestjs/jest#8756 is the only relevant change that would cause this issue.

@ghost
Copy link
Author

ghost commented Feb 21, 2020

Hi @ahnpnl, I am getting the same issue. This time you can found a repository to reproduce it here:

Only run: npm test, you don't need setup Docker or the database to reproduce it.

@ghost ghost reopened this Feb 21, 2020
@ahnpnl
Copy link
Collaborator

ahnpnl commented Feb 22, 2020

Thanks for your repo @localnet , I will take a look when I have some free times

@ahnpnl
Copy link
Collaborator

ahnpnl commented Mar 27, 2020

Hi @localnet, please check related issues #1391 #1445 . In summary Jest will support this in Jest 26. For now these setup files won’t be able to reach transformer.

@deklanw
Copy link

deklanw commented May 20, 2020

Since this fix has been pushed back until Jest 27 (see jestjs/jest#8751) is there a temp fix I could use until then? My usecase is also TypeORM

import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
^^^^^^

SyntaxError: Cannot use import statement outside a module

Specifically, I assume when TypeORM loads entities when establishing a connection that it's using require for these ts files

entities: [path.join(__dirname, '../entities/*.{ts,js}')],

@MaximeBernard
Copy link

MaximeBernard commented May 25, 2021

Jest 27 is out 🎉 🎉

@ahnpnl worth reopening the issue?

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

No branches or pull requests

5 participants