From adb0a62590ad385b67c1e9548e2c8c512820ff01 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Fri, 12 Aug 2022 19:12:06 -0400 Subject: [PATCH] Use ts-check instead of relying on ts-node, fix absolute path resolution in tests --- packages/jest-utils/package.json | 1 + packages/jest-utils/src/index.ts | 1 + packages/jest-utils/{vite.config.mts => vite.config.ts} | 0 .../files/{jest.config.ts__tmpl__ => jest.config.js__tmpl__} | 1 + .../src/generators/ts-iso/files/tsconfig.spec.json__tmpl__ | 3 +++ packages/nx-plugin/src/generators/ts-iso/index.ts | 2 -- packages/nx-plugin/src/utils/dependencies.ts | 1 - 7 files changed, 6 insertions(+), 3 deletions(-) rename packages/jest-utils/{vite.config.mts => vite.config.ts} (100%) rename packages/nx-plugin/src/generators/ts-iso/files/{jest.config.ts__tmpl__ => jest.config.js__tmpl__} (87%) diff --git a/packages/jest-utils/package.json b/packages/jest-utils/package.json index 7d51f2d..cf58c6b 100644 --- a/packages/jest-utils/package.json +++ b/packages/jest-utils/package.json @@ -3,6 +3,7 @@ "description": "Eterna standard Jest setup and utilities", "version": "1.1.0", "license": "BSD-3-Clause", + "type": "module", "scripts": { "prepublishOnly": "nx build", "build": "vite build", diff --git a/packages/jest-utils/src/index.ts b/packages/jest-utils/src/index.ts index 6dd4edb..0830f54 100644 --- a/packages/jest-utils/src/index.ts +++ b/packages/jest-utils/src/index.ts @@ -14,6 +14,7 @@ export function getConfig(mode: 'typescript' | 'vue') { '!**/*.(spec|test).(js|mjs|cjs|ts|mts|cts)', '!**/(__tests__|test|tests|spec)/**/*.(js|mjs|cjs|ts|mts|cts)', ], + modulePaths: ['/src/'], globals: { 'ts-jest': { tsconfig: 'tsconfig.spec.json', diff --git a/packages/jest-utils/vite.config.mts b/packages/jest-utils/vite.config.ts similarity index 100% rename from packages/jest-utils/vite.config.mts rename to packages/jest-utils/vite.config.ts diff --git a/packages/nx-plugin/src/generators/ts-iso/files/jest.config.ts__tmpl__ b/packages/nx-plugin/src/generators/ts-iso/files/jest.config.js__tmpl__ similarity index 87% rename from packages/nx-plugin/src/generators/ts-iso/files/jest.config.ts__tmpl__ rename to packages/nx-plugin/src/generators/ts-iso/files/jest.config.js__tmpl__ index f644f5b..953c32e 100644 --- a/packages/nx-plugin/src/generators/ts-iso/files/jest.config.ts__tmpl__ +++ b/packages/nx-plugin/src/generators/ts-iso/files/jest.config.js__tmpl__ @@ -1,3 +1,4 @@ +// @ts-check import { getConfig } from '@eternagame/jest-utils'; export default getConfig('typescript'); diff --git a/packages/nx-plugin/src/generators/ts-iso/files/tsconfig.spec.json__tmpl__ b/packages/nx-plugin/src/generators/ts-iso/files/tsconfig.spec.json__tmpl__ index b707f8f..79ec3d1 100644 --- a/packages/nx-plugin/src/generators/ts-iso/files/tsconfig.spec.json__tmpl__ +++ b/packages/nx-plugin/src/generators/ts-iso/files/tsconfig.spec.json__tmpl__ @@ -3,6 +3,9 @@ "references": [ {"path": "./tsconfig.build.json"} ], + "compilerOptions": { + "baseUrl": "src" + }, "include": [ "**/*.spec.ts", "**/*.test.ts", diff --git a/packages/nx-plugin/src/generators/ts-iso/index.ts b/packages/nx-plugin/src/generators/ts-iso/index.ts index d21d4bb..99b73dd 100644 --- a/packages/nx-plugin/src/generators/ts-iso/index.ts +++ b/packages/nx-plugin/src/generators/ts-iso/index.ts @@ -92,8 +92,6 @@ function updatePackageJson(tree: Tree, options: NormalizedSchema) { '@types/jest', 'ts-jest', 'typescript', - // For loading TS jest config files - 'ts-node', ]), ); } diff --git a/packages/nx-plugin/src/utils/dependencies.ts b/packages/nx-plugin/src/utils/dependencies.ts index 5d3f48d..cdb5a2b 100644 --- a/packages/nx-plugin/src/utils/dependencies.ts +++ b/packages/nx-plugin/src/utils/dependencies.ts @@ -46,7 +46,6 @@ const VERSIONS = { jest: '^27.5.0', '@types/jest': '^27.4.0', 'ts-jest': '^27.1.3', - 'ts-node': '^10.9.1', } as const; export default function getDependencyVersions(