refactor(core): Support writing tests in cli/src (no-changelog) (#9646)

This commit is contained in:
Iván Ovejero 2024-06-06 12:18:47 +02:00 committed by GitHub
parent b45f3dc9fb
commit 65cd2e8803
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 4 deletions

View file

@ -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] = '<rootDir>' + (baseUrl ? `/${baseUrl.replace(/^\.\//, '')}` : '') + mapping + '/$1';
acc[path] = mapping.startsWith('/test')
? '<rootDir>' + mapping + '/$1'
: '<rootDir>' + (baseUrl ? `/${baseUrl.replace(/^\.\//, '')}` : '') + mapping + '/$1';
return acc;
}, {}),
setupFilesAfterEnv: ['jest-expect-message'],

View file

@ -6,5 +6,5 @@
"tsBuildInfoFile": "dist/build.tsbuildinfo"
},
"include": ["src/**/*.ts"],
"exclude": ["test/**"]
"exclude": ["test/**", "src/**/__tests__/**"]
}

View file

@ -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