Skip to content

Commit 3344cea

Browse files
committed
feat: Update Jest configurations, enhance module mappings, and add new test configurations for multiple packages
1 parent e448235 commit 3344cea

File tree

10 files changed

+119
-16
lines changed

10 files changed

+119
-16
lines changed

jest.base.config.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ export default {
77
'ts-jest',
88
{
99
useESM: true,
10-
tsconfig: 'tsconfig.base.json'
10+
tsconfig: '<rootDir>/tsconfig.base.json'
1111
}
1212
]
1313
},
1414
moduleNameMapper: {
15-
'^@mixcore/(.*)$': '<rootDir>/packages/$1/src'
15+
'^@mixcore/(.*)$': '<rootDir>/packages/$1/src',
16+
'^(\\.{1,2}/.*)\\.js$': '$1'
1617
},
1718
transformIgnorePatterns: [
1819
'node_modules/(?!(.*\\.mjs$|@mixcore/.*))'
19-
]
20+
],
21+
moduleFileExtensions: ['ts', 'js', 'json', 'node']
2022
};

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
],
99
"scripts": {
1010
"build": "lerna run build --stream",
11-
"test": "lerna run test --stream",
12-
"lint": "lerna run lint --stream"
11+
"test": "npm run build && lerna run test --stream",
12+
"lint": "lerna run lint --stream",
13+
"compile": "tsc --build tsconfig.base.json"
1314
},
1415
"devDependencies": {
1516
"@jest/types": "^30.0.0",

packages/api/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './api-services';
2-
export { ApiResult, RestApiResult, ApiService } from './api-services';
2+
export type { ApiResult, RestApiResult } from './api-services';
3+
export { ApiService } from './api-services';
34
export * from './createMixcoreSdk';

packages/database/jest.config.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import baseConfig from '../../jest.base.config.mjs';
2+
import { fileURLToPath } from 'url';
3+
import path from 'path';
4+
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
6+
7+
export default {
8+
...baseConfig,
9+
displayName: '@mixcore/database',
10+
testMatch: ['**/tests/**/*.test.ts'],
11+
transform: {
12+
'^.+\\.ts$': [
13+
'ts-jest',
14+
{
15+
useESM: true,
16+
tsconfig: path.resolve(__dirname, '../../tsconfig.base.json')
17+
}
18+
]
19+
},
20+
extensionsToTreatAsEsm: ['.ts'],
21+
moduleNameMapper: {
22+
'^(\\.{1,2}/.*)\\.js$': '$1',
23+
'^@mixcore/api$': '<rootDir>/../../packages/api/src',
24+
'^@mixcore/database$': '<rootDir>/src'
25+
}
26+
};

packages/file/jest.config.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import baseConfig from '../../jest.base.config.mjs';
2+
import { fileURLToPath } from 'url';
3+
import path from 'path';
4+
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
6+
7+
export default {
8+
...baseConfig,
9+
displayName: '@mixcore/file',
10+
testMatch: ['**/tests/**/*.test.ts'],
11+
transform: {
12+
'^.+\\.ts$': [
13+
'ts-jest',
14+
{
15+
useESM: true,
16+
tsconfig: path.resolve(__dirname, '../../tsconfig.base.json')
17+
}
18+
]
19+
},
20+
extensionsToTreatAsEsm: ['.ts'],
21+
moduleNameMapper: {
22+
'^(\\.{1,2}/.*)\\.js$': '$1',
23+
'^@mixcore/api$': '<rootDir>/../../packages/api/src',
24+
'^@mixcore/file$': '<rootDir>/src'
25+
}
26+
};

packages/template/jest.config.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import baseConfig from '../../jest.base.config.mjs';
2+
import { fileURLToPath } from 'url';
3+
import path from 'path';
4+
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
6+
7+
export default {
8+
...baseConfig,
9+
displayName: '@mixcore/template',
10+
testMatch: ['**/tests/**/*.test.ts'],
11+
transform: {
12+
'^.+\\.ts$': [
13+
'ts-jest',
14+
{
15+
useESM: true,
16+
tsconfig: path.resolve(__dirname, '../../tsconfig.base.json')
17+
}
18+
]
19+
},
20+
extensionsToTreatAsEsm: ['.ts'],
21+
moduleNameMapper: {
22+
'^(\\.{1,2}/.*)\\.js$': '$1',
23+
'^@mixcore/api$': '<rootDir>/../../packages/api/src',
24+
'^@mixcore/template$': '<rootDir>/src'
25+
}
26+
};

packages/user/jest.config.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import baseConfig from '../../jest.base.config.mjs';
2+
import { fileURLToPath } from 'url';
3+
import path from 'path';
4+
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
6+
7+
export default {
8+
...baseConfig,
9+
displayName: '@mixcore/user',
10+
testMatch: ['**/tests/**/*.test.ts'],
11+
transform: {
12+
'^.+\\.ts$': [
13+
'ts-jest',
14+
{
15+
useESM: true,
16+
tsconfig: path.resolve(__dirname, '../../tsconfig.base.json')
17+
}
18+
]
19+
},
20+
extensionsToTreatAsEsm: ['.ts'],
21+
moduleNameMapper: {
22+
'^(\\.{1,2}/.*)\\.js$': '$1',
23+
'^@mixcore/api$': '<rootDir>/../../packages/api/src',
24+
'^@mixcore/user$': '<rootDir>/src'
25+
}
26+
};

packages/user/tests/user-services.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('UserServices', () => {
66
let userServices: UserServices;
77

88
beforeEach(() => {
9-
api = new ApiService({ apiBaseUrl: 'http://localhost/api/' });
9+
api = new ApiService({ apiBaseUrl: 'https://mixcore.net/api/' });
1010
userServices = new UserServices(api);
1111
});
1212

pnpm-lock.yaml

Lines changed: 3 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsconfig.base.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"strict": false,
1010
"noImplicitAny": false,
1111
"esModuleInterop": true,
12+
"isolatedModules": true,
1213
"moduleResolution": "node",
1314
"forceConsistentCasingInFileNames": true,
1415
"skipLibCheck": true,

0 commit comments

Comments
 (0)