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
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'],