Skip to content

Commit 36a4f61

Browse files
elbwalker package directories
1 parent 9ef5fed commit 36a4f61

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

packages/config/jest/index.js

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
import path from 'path';
2+
import { fileURLToPath } from 'url';
3+
4+
function getModuleMapper() {
5+
// Check if we're in watch mode (dev) or regular test mode
6+
const isWatchMode = process.argv.includes('--watchAll');
7+
8+
// Use either src or dist folder based on watch mode
9+
const targetDir = isWatchMode ? '/src' : '/dist';
10+
11+
const packagesDir = path.join(
12+
path.dirname(fileURLToPath(import.meta.url)),
13+
'..',
14+
'..',
15+
'/',
16+
);
17+
18+
function getDirectory(dir, target = targetDir) {
19+
return path.join(packagesDir, dir, target);
20+
}
21+
22+
return {
23+
'^@elbwalker/jest$1': getDirectory('config/jest$1', ''),
24+
'^@elbwalker/types': getDirectory('types', 'src'),
25+
'^@elbwalker/utils': getDirectory('utils'),
26+
'^@elbwalker/walker.js': getDirectory('sources/walkerjs'),
27+
'^@elbwalker/destination-web-(.*)$': getDirectory('destinations/web/$1'),
28+
'^@elbwalker/destination-node-(.*)$': getDirectory('destinations/node/$1'),
29+
'^@elbwalker/source-(.*)$': getDirectory('sources/$1'),
30+
};
31+
}
32+
133
const config = {
234
transform: {
335
'^.+\\.(t|j)sx?$': [
@@ -21,16 +53,8 @@ const config = {
2153
moduleFileExtensions: ['js', 'ts', 'mjs'],
2254
rootDir: 'src',
2355
moduleDirectories: ['node_modules', 'src'],
24-
// extensionsToTreatAsEsm: ['.ts', '.tsx'],
25-
// moduleNameMapper: {
26-
// '^@elbwalker/(.*)$': '<rootDir>/../../../$1/src',
27-
// },
28-
// moduleNameMapper: {
29-
// '^@elbwalker/(.*)$': '<rootDir>/../../../$1/',
30-
// },
31-
// transformIgnorePatterns: [
32-
// '/node_modules/(?!(@elbwalker)/)',
33-
// ],
56+
extensionsToTreatAsEsm: ['.ts', '.tsx'],
57+
moduleNameMapper: getModuleMapper(),
3458
};
3559

3660
export default config;

0 commit comments

Comments
 (0)