From 65cd2e88036d386db3d6ff1833e614fc6056614e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Thu, 6 Jun 2024 12:18:47 +0200 Subject: [PATCH] refactor(core): Support writing tests in `cli/src` (no-changelog) (#9646) --- jest.config.js | 6 ++++-- packages/cli/tsconfig.build.json | 2 +- packages/cli/tsconfig.json | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/jest.config.js b/jest.config.js index f3f7824c14..3caac38ef9 100644 --- a/jest.config.js +++ b/jest.config.js @@ -24,9 +24,11 @@ const config = { // This resolve the path mappings from the tsconfig relative to each jest.config.js moduleNameMapper: Object.entries(paths || {}).reduce((acc, [path, [mapping]]) => { path = `^${path.replace(/\/\*$/, '/(.*)$')}`; - mapping = mapping.replace(/^\.\/(?:(.*)\/)?\*$/, '$1'); + mapping = mapping.replace(/^\.?\.\/(?:(.*)\/)?\*$/, '$1'); mapping = mapping ? `/${mapping}` : ''; - acc[path] = '' + (baseUrl ? `/${baseUrl.replace(/^\.\//, '')}` : '') + mapping + '/$1'; + acc[path] = mapping.startsWith('/test') + ? '' + mapping + '/$1' + : '' + (baseUrl ? `/${baseUrl.replace(/^\.\//, '')}` : '') + mapping + '/$1'; return acc; }, {}), setupFilesAfterEnv: ['jest-expect-message'], diff --git a/packages/cli/tsconfig.build.json b/packages/cli/tsconfig.build.json index 1e8a2ff7fa..55afe8b409 100644 --- a/packages/cli/tsconfig.build.json +++ b/packages/cli/tsconfig.build.json @@ -6,5 +6,5 @@ "tsBuildInfoFile": "dist/build.tsbuildinfo" }, "include": ["src/**/*.ts"], - "exclude": ["test/**"] + "exclude": ["test/**", "src/**/__tests__/**"] } diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index 86b8d550e8..8c4325a55b 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -8,7 +8,9 @@ "baseUrl": "src", "paths": { "@/*": ["./*"], - "@db/*": ["./databases/*"] + "@db/*": ["./databases/*"], + "@test/*": ["../test/shared/*"], + "@test-integration/*": ["../test/integration/shared/*"] }, "tsBuildInfoFile": "dist/typecheck.tsbuildinfo", // TODO: remove all options below this line