diff --git a/package.json b/package.json index f79f76d..7c44d49 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,7 @@ "transform": { "^.+\\.tsx?$": "ts-jest" }, + "resolver": "/test/resolver.cjs", "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", "moduleFileExtensions": [ "ts", @@ -124,7 +125,7 @@ ], "globals": { "ts-jest": { - "tsConfig": "test/tsconfig.tests.json" + "tsconfig": "test/tsconfig.json" } }, "collectCoverage": true, diff --git a/test/resolver.cjs b/test/resolver.cjs new file mode 100644 index 0000000..4698165 --- /dev/null +++ b/test/resolver.cjs @@ -0,0 +1,9 @@ +const path = require("path") +const srcDir = path.resolve(__dirname, "..", "src") + +module.exports = (path, options) => { + if (options.basedir.startsWith(srcDir) && path.endsWith(".js")) { + return options.defaultResolver(path.substring(0, path.length - 3) + ".ts", options); + } + return options.defaultResolver(path, options); +}; \ No newline at end of file diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 0000000..0db4f80 --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "es2015", + "dom" + ], + "module": "commonjs", + "noImplicitAny": false, + "sourceMap": true, + "allowJs": true, + "types": [ + "node", + "jest" + ] + }, + "include": [ + "./node/**/*.spec.ts" + ] +} \ No newline at end of file diff --git a/test/tsconfig.tests.json b/test/tsconfig.tests.json deleted file mode 100644 index 40ed092..0000000 --- a/test/tsconfig.tests.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "lib": [ "es2015", "dom" ], - "module": "commonjs", - "noImplicitAny": false, - "sourceMap": true, - "allowJs": true, - "types": [ "node", "jest" ] - }, - "include": [ - "./**/*" - ] -} \ No newline at end of file