Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/chrome-devtools/testing/jest.config.ut.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
...getOtterJestBaseConfig(rootDir),
...getJestUnitTestConfig(),
transformIgnorePatterns: ['^.+\\.js$'],
testEnvironment: 'node',
globals: {
chrome: {
runtime: {},
Expand Down
4 changes: 3 additions & 1 deletion apps/github-cascading-app/testing/jest.config.ut.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ const rootDir = path.join(__dirname, '..');
module.exports = {
...createDefaultPreset(getTsJestBaseConfig()),
...getOtterJestBaseConfig(rootDir),
...getJestUnitTestConfig()
...getJestUnitTestConfig({
testEnvironment: 'node'
})
};
6 changes: 4 additions & 2 deletions apps/palette-generator/testing/jest.config.ut.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const rootDir = path.join(__dirname, '..');
module.exports = {
...createDefaultPreset(getTsJestBaseConfig()),
...getOtterJestBaseConfig(rootDir),
...getJestUnitTestConfig(),
transformIgnorePatterns: ['^.+\\.js$']
...getJestUnitTestConfig({
testEnvironment: 'node',
transformIgnorePatterns: ['^.+\\.js$']
})
};
4 changes: 3 additions & 1 deletion apps/vscode-extension/testing/jest.config.ut.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ const rootDir = path.join(__dirname, '..');
module.exports = {
...createDefaultPreset(getTsJestBaseConfig()),
...getOtterJestBaseConfig(rootDir),
...getJestUnitTestConfig()
...getJestUnitTestConfig({
testEnvironment: 'node'
})
};
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@
"@angular/platform-browser": "~20.3.13",
"@angular/platform-browser-dynamic": "~20.3.13",
"@angular/router": "~20.3.13",
"@babel/core": "~7.28.0",
"@babel/preset-typescript": "~7.28.0",
"@commitlint/cli": "^19.0.0",
"@commitlint/config-angular": "^19.0.0",
"@commitlint/config-conventional": "^19.0.0",
Expand Down Expand Up @@ -225,14 +223,14 @@
"ag-grid-community": "~32.3.0",
"angular-eslint": "~20.6.0",
"angular-split": "^20.0.0",
"babel-loader": "^10.0.0",
"bootstrap": "5.3.7",
"bootstrap-icons": "^1.11.3",
"browserslist": "^4.21.4",
"clipboard": "^2.0.11",
"commit-and-tag-version": "^12.0.0",
"concurrently": "^9.1.0",
"cpy-cli": "^6.0.0",
"cross-env": "^7.0.3",
"editorconfig-checker": "^6.0.1",
"eslint": "~9.39.0",
"eslint-import-resolver-node": "~0.3.9",
Expand Down
3 changes: 2 additions & 1 deletion packages/@ama-mcp/angular/testing/jest.config.ut.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
testPathIgnorePatterns: [
'<rootDir>/builders/.*',
'<rootDir>/schematics/.*'
]
],
testEnvironment: 'node'
})
};
3 changes: 2 additions & 1 deletion packages/@ama-mcp/core/testing/jest.config.ut.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
testPathIgnorePatterns: [
'<rootDir>/builders/.*',
'<rootDir>/schematics/.*'
]
],
testEnvironment: 'node'
})
};
3 changes: 2 additions & 1 deletion packages/@ama-mcp/otter/testing/jest.config.ut.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
testPathIgnorePatterns: [
'<rootDir>/builders/.*',
'<rootDir>/schematics/.*'
]
],
testEnvironment: 'node'
})
};
6 changes: 4 additions & 2 deletions packages/@ama-mfe/messages/testing/jest.config.ut.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const rootDir = path.join(__dirname, '..');
module.exports = {
...createDefaultPreset(getTsJestBaseConfig()),
...getOtterJestBaseConfig(rootDir),
...getJestUnitTestConfig(),
setupFilesAfterEnv: ['<rootDir>/testing/setup-jest.ts']
...getJestUnitTestConfig({
setupFilesAfterEnv: ['<rootDir>/testing/setup-jest.ts'],
testEnvironment: 'node'
}),
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ module.exports = {
...getJestUnitTestConfig({
testPathIgnorePatterns: [
'<rootDir>/src/.*'
]
],
testEnvironment: 'node',
setupFilesAfterEnv: ['<rootDir>/testing/setup-jest.builders.ts']
}),
setupFilesAfterEnv: ['<rootDir>/testing/setup-jest.builders.ts']
};
5 changes: 1 addition & 4 deletions packages/@ama-openapi/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
}
},
"devDependencies": {
"@babel/core": "~7.28.0",
"@babel/preset-env": "~7.28.0",
"@babel/preset-typescript": "~7.28.0",
"@angular/compiler": "~20.3.13",
"@compodoc/compodoc": "^1.1.32",
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
"@nx/eslint": "~21.6.0",
Expand All @@ -71,7 +69,6 @@
"@types/yargs": "~17.0.33",
"@typescript-eslint/parser": "~8.47.0",
"angular-eslint": "~20.6.0",
"babel-jest": "^30.0.5",
"chokidar": "^4.0.3",
"cpy-cli": "^6.0.0",
"eslint": "~9.39.0",
Expand Down
6 changes: 0 additions & 6 deletions packages/@ama-openapi/cli/testing/babel.config.mjs

This file was deleted.

9 changes: 3 additions & 6 deletions packages/@ama-openapi/cli/testing/jest.config.ut.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ const rootDir = path.join(__dirname, '..');
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
module.exports = {
...getOtterJestBaseConfig(rootDir),
...getJestUnitTestConfig(),
transform: {
'^.+\\.([mc]?[tj]sx?)$': ['babel-jest', { configFile: path.join(__dirname, 'babel.config.mjs') }]
},
extensionsToTreatAsEsm: ['.mts'],
setupFilesAfterEnv: ['<rootDir>/testing/setup-jest.ts']
...getJestUnitTestConfig({
setupFilesAfterEnv: ['<rootDir>/testing/setup-jest.ts']
}),
};
9 changes: 3 additions & 6 deletions packages/@ama-openapi/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"copy:renovate": "yarn cpy 'renovate/*.json' dist/renovate",
"build:source": "tsc -b tsconfig.build.json && yarn cpy package.json dist/",
"build": "yarn nx build ama-openapi-core",
"postbuild": "patch-package-json-main"
"postbuild": "patch-package-json-main",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules yarn jest --config=jest.config.cjs"
},
"exports": {
"./package.json": {
Expand Down Expand Up @@ -53,9 +54,7 @@
}
},
"devDependencies": {
"@babel/core": "~7.28.0",
"@babel/preset-env": "~7.28.0",
"@babel/preset-typescript": "~7.28.0",
"@angular/platform-browser-dynamic": "~20.3.13",
"@compodoc/compodoc": "^1.1.32",
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
"@nx/eslint": "~21.6.0",
Expand All @@ -74,8 +73,6 @@
"@types/semver": "^7.3.13",
"@typescript-eslint/parser": "~8.47.0",
"angular-eslint": "~20.6.0",
"babel-jest": "^30.0.5",
"babel-plugin-transform-import-meta": "^2.0.0",
"cpy-cli": "^6.0.0",
"eslint": "~9.39.0",
"eslint-import-resolver-node": "~0.3.9",
Expand Down
3 changes: 2 additions & 1 deletion packages/@ama-openapi/core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
},
"lint": {},
"test": {
"executor": "nx:run-script",
"options": {
"jestConfig": "{projectRoot}/jest.config.cjs"
"script": "test"
}
},
"prepare-publish": {},
Expand Down
9 changes: 0 additions & 9 deletions packages/@ama-openapi/core/testing/babel.config.mjs

This file was deleted.

19 changes: 19 additions & 0 deletions packages/@ama-openapi/core/testing/jest-resolver.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Custom Jest resolver to map .mjs imports to .mts source files
* Required for ESM support with .mts files
* @see https://kulshekhar.github.io/ts-jest/docs/guides/esm-support#resolve-mjsmts-extensions
*/
module.exports = (path, options) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if required even with the pathMapper

const mjsExtRegex = /\.mjs$/i;
const resolver = options.defaultResolver;

if (mjsExtRegex.test(path)) {
try {
return resolver(path.replace(mjsExtRegex, '.mts'), options);
} catch {
// Fall back to default resolver if .mts file doesn't exist
}
}

return resolver(path, options);
};
12 changes: 9 additions & 3 deletions packages/@ama-openapi/core/testing/jest.config.it.cjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
const path = require('node:path');
const { getTsJestBaseConfig, getOtterJestBaseConfig, getJestIntegrationTestConfig } = require('@o3r/test-helpers');
const { createDefaultPreset } = require('ts-jest');
const { createJsWithTsEsmPreset } = require('ts-jest');

const rootDir = path.join(__dirname, '..');

const tsJestConfig = { ...getTsJestBaseConfig(), useESM: true, diagnostics: { ignoreCodes: [151002] } };

/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
module.exports = {
...createDefaultPreset(getTsJestBaseConfig()),
...createJsWithTsEsmPreset(tsJestConfig),
...getOtterJestBaseConfig(rootDir),
...getJestIntegrationTestConfig()
...getJestIntegrationTestConfig(),
testEnvironment: 'node',
extensionsToTreatAsEsm: ['.ts', '.mts'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be inherited from otterBaseConfig

resolver: '<rootDir>/testing/jest-resolver.cjs',
injectGlobals: true,
};
19 changes: 12 additions & 7 deletions packages/@ama-openapi/core/testing/jest.config.ut.cjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
const path = require('node:path');
const { getOtterJestBaseConfig, getJestUnitTestConfig } = require('@o3r/test-helpers');
const { getOtterJestBaseConfig, getJestUnitTestConfig, getTsJestBaseConfig } = require('@o3r/test-helpers');
const { createJsWithTsEsmPreset } = require('ts-jest');

const rootDir = path.join(__dirname, '..');

const tsJestConfig = { ...getTsJestBaseConfig(), useESM: true, diagnostics: { ignoreCodes: [151002] } };

/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
module.exports = {
...createJsWithTsEsmPreset(tsJestConfig),
...getOtterJestBaseConfig(rootDir),
...getJestUnitTestConfig(),
transform: {
'^.+\\.([mc]?[tj]sx?)$': ['babel-jest', { configFile: path.join(__dirname, 'babel.config.mjs') }]
},
extensionsToTreatAsEsm: ['.mts'],
setupFilesAfterEnv: ['<rootDir>/testing/setup-jest.ts']
...getJestUnitTestConfig({
setupFilesAfterEnv: ['<rootDir>/testing/setup-jest.mjs'],
testEnvironment: 'node',
extensionsToTreatAsEsm: ['.ts', '.mts'],
resolver: '<rootDir>/testing/jest-resolver.cjs',
injectGlobals: true
}),
};
1 change: 1 addition & 0 deletions packages/@ama-openapi/core/testing/setup-jest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Jest setup file for ama-openapi-core
16 changes: 16 additions & 0 deletions packages/@ama-openapi/core/testing/setup-jest.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Jest setup file for ESM mode
* Makes Jest globals available without explicit imports in test files
*/
import * as jestGlobals from '@jest/globals';

// Make all Jest globals available
globalThis.jest = jestGlobals.jest;
globalThis.expect = jestGlobals.expect;
globalThis.describe = jestGlobals.describe;
globalThis.it = jestGlobals.it;
globalThis.test = jestGlobals.test;
globalThis.beforeEach = jestGlobals.beforeEach;
globalThis.afterEach = jestGlobals.afterEach;
globalThis.beforeAll = jestGlobals.beforeAll;
globalThis.afterAll = jestGlobals.afterAll;
1 change: 1 addition & 0 deletions packages/@ama-openapi/core/testing/setup-jest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Jest setup file for ama-openapi-core
9 changes: 6 additions & 3 deletions packages/@ama-openapi/core/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
"extends": "../../../tsconfig.jest",
"compilerOptions": {
"resolveJsonModule": true,
"module": "ESNext",
"module": "nodenext",
"target": "ESNext",
"allowJs": true,
"composite": true,
"rootDir": "."
"rootDir": ".",
"moduleResolution": "nodenext",
"isolatedModules": true
},
"include": [
"**/*.spec.ts"
"**/*.spec.ts",
"testing/**/*.ts"
],
"exclude": [],
"references": [
Expand Down
4 changes: 3 additions & 1 deletion packages/@ama-openapi/create/testing/jest.config.it.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ const rootDir = path.join(__dirname, '..');
module.exports = {
...createDefaultPreset(getTsJestBaseConfig()),
...getOtterJestBaseConfig(rootDir),
...getJestIntegrationTestConfig()
...getJestIntegrationTestConfig({
testEnvironment: 'node'
})
};
8 changes: 3 additions & 5 deletions packages/@ama-openapi/redocly-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"ng": "yarn nx",
"build:source": "tsc -b tsconfig.build.json && yarn cpy package.json dist/",
"build": "yarn nx build ama-openapi-redocly",
"postbuild": "patch-package-json-main"
"postbuild": "patch-package-json-main",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules yarn jest --config=jest.config.cjs"
},
"dependencies": {
"@ama-openapi/core": "workspace:~",
Expand All @@ -45,9 +46,7 @@
}
},
"devDependencies": {
"@babel/core": "~7.28.0",
"@babel/preset-env": "~7.28.0",
"@babel/preset-typescript": "~7.28.0",
"@angular/compiler": "~20.3.13",
"@compodoc/compodoc": "^1.1.32",
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
"@nx/eslint": "~21.6.0",
Expand All @@ -68,7 +67,6 @@
"@types/yargs": "~17.0.33",
"@typescript-eslint/parser": "~8.47.0",
"angular-eslint": "~20.6.0",
"babel-jest": "^30.0.5",
"cpy-cli": "^6.0.0",
"eslint": "~9.39.0",
"eslint-import-resolver-node": "~0.3.9",
Expand Down
4 changes: 2 additions & 2 deletions packages/@ama-openapi/redocly-plugin/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
},
"lint": {},
"test": {
"executor": "nx:run-script",
"options": {
"jestConfig": "{projectRoot}/jest.config.cjs",
"passWithNoTests": true
"script": "test"
}
},
"set-version": {},
Expand Down

This file was deleted.

19 changes: 19 additions & 0 deletions packages/@ama-openapi/redocly-plugin/testing/jest-resolver.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Custom Jest resolver to map .mjs imports to .mts source files
* Required for ESM support with .mts files
* @see https://kulshekhar.github.io/ts-jest/docs/guides/esm-support#resolve-mjsmts-extensions
*/
module.exports = (path, options) => {
const mjsExtRegex = /\.mjs$/i;
const resolver = options.defaultResolver;

if (mjsExtRegex.test(path)) {
try {
return resolver(path.replace(mjsExtRegex, '.mts'), options);
} catch {
// Fall back to default resolver if .mts file doesn't exist
}
}

return resolver(path, options);
};
Loading