Skip to content

Commit e448235

Browse files
committed
feat: Update Jest configurations, enhance module support, and refactor test imports across packages
1 parent c35a2d7 commit e448235

File tree

12 files changed

+91
-19
lines changed

12 files changed

+91
-19
lines changed

jest.base.config.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export default {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
extensionsToTreatAsEsm: ['.ts'],
5+
transform: {
6+
'^.+\\.ts$': [
7+
'ts-jest',
8+
{
9+
useESM: true,
10+
tsconfig: 'tsconfig.base.json'
11+
}
12+
]
13+
},
14+
moduleNameMapper: {
15+
'^@mixcore/(.*)$': '<rootDir>/packages/$1/src'
16+
},
17+
transformIgnorePatterns: [
18+
'node_modules/(?!(.*\\.mjs$|@mixcore/.*))'
19+
]
20+
};

jest.config.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
module.exports = {
1+
export default {
22
preset: 'ts-jest',
33
testEnvironment: 'node',
4-
moduleFileExtensions: ['ts', 'js', 'json'],
4+
extensionsToTreatAsEsm: ['.ts'],
5+
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
56
transform: {
6-
'^.+\\.ts$': 'ts-jest',
7+
'^.+\\.ts$': [
8+
'ts-jest',
9+
{
10+
useESM: true,
11+
tsconfig: 'tsconfig.base.json',
12+
}
13+
]
714
},
815
testMatch: ['**/tests/**/*.test.ts'],
916
moduleNameMapper: {
1017
'^@mixcore/(.*)$': '<rootDir>/packages/$1/src',
18+
'^(\\.{1,2}/.*)\\.js$': '$1',
1119
},
12-
globals: {
13-
'ts-jest': {
14-
tsconfig: 'tsconfig.base.json',
15-
},
16-
},
20+
transformIgnorePatterns: [
21+
'node_modules/(?!(.*\\.mjs$|@mixcore/.*))'
22+
]
1723
};

packages/api/jest.config.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import baseConfig from '../../jest.base.config.mjs';
2+
3+
export default {
4+
...baseConfig,
5+
transform: {
6+
'^.+\\.ts$': [
7+
'ts-jest',
8+
{
9+
useESM: true,
10+
tsconfig: 'tsconfig.json'
11+
}
12+
]
13+
},
14+
moduleNameMapper: {
15+
...baseConfig.moduleNameMapper,
16+
'^@mixcore/(.*)$': '<rootDir>/../$1/src'
17+
}
18+
};

packages/api/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44
"main": "dist/index.js",
55
"module": "dist/index.esm.js",
66
"types": "dist/index.d.ts",
7+
"type": "module",
78
"description": "API bootstrap, core API clients, and SDK entrypoint for Mixcore SDK (framework-agnostic, TypeScript)",
89
"scripts": {
910
"build": "tsup src/index.ts --dts --format esm,cjs --out-dir dist",
1011
"test": "jest",
1112
"lint": "eslint src --ext .ts"
1213
},
1314
"dependencies": {
14-
"@mixcore/shared": "workspace:*",
15-
"@mixcore/file": "workspace:*",
16-
"@mixcore/template": "workspace:*",
17-
"@mixcore/user": "workspace:*"
15+
"@mixcore/shared": "workspace:*"
1816
},
1917
"license": "SEE LICENSE IN LICENSE",
2018
"repository": "https://github.com/mixcore/javascript-sdk",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// CommonJS wrapper for ApiService
2+
const { ApiService } = require('./api-services');
3+
module.exports = { ApiService };

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ApiService } from './api-services';
1+
import { ApiService } from '../src/api-services';
22

33
describe('ApiService', () => {
44
const config = {

packages/api/tests/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

packages/config/jest.config.mjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export default {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
extensionsToTreatAsEsm: ['.ts'],
5+
transform: {
6+
'^.+\\.ts$': [
7+
'ts-jest',
8+
{
9+
useESM: true,
10+
tsconfig: 'tsconfig.json'
11+
}
12+
]
13+
},
14+
moduleNameMapper: {
15+
'^@mixcore/(.*)$': '<rootDir>/../$1/src'
16+
}
17+
};

packages/config/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
"main": "dist/index.js",
55
"module": "dist/index.esm.js",
66
"types": "dist/index.d.ts",
7+
"type": "module",
78
"description": "Configuration domain services for Mixcore SDK (framework-agnostic, TypeScript)",
89
"scripts": {
910
"build": "tsup src/index.ts --dts --format esm,cjs --out-dir dist",
1011
"test": "jest",
1112
"lint": "eslint src --ext .ts"
1213
},
1314
"dependencies": {
14-
"@mixcore/shared": "workspace:*"
15+
"@mixcore/shared": "workspace:*",
16+
"@mixcore/api": "workspace:*"
1517
},
1618
"license": "SEE LICENSE IN LICENSE",
1719
"repository": "https://github.com/mixcore/javascript-sdk",

packages/config/tests/configuration-services.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ApiService } from './api-services';
2-
import { ConfigurationServices, ConfigurationUpload } from './configuration-services';
1+
import { ApiService } from '@mixcore/api';
2+
import { ConfigurationServices, ConfigurationUpload } from '../src/configuration-services';
33

44
describe('ConfigurationServices', () => {
55
let api: ApiService;

0 commit comments

Comments
 (0)