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
6 changes: 3 additions & 3 deletions .github/workflows/package-js-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ jobs:
)
strategy:
matrix:
include:
node-version:
# Always run: Latest Node version (fast feedback on PRs)
- node-version: '22'
- '22'
# Master and full-ci label: Minimum supported Node version (full coverage)
- node-version: '20'
- '20'
exclude:
# Skip minimum dependency matrix on regular PRs (run only on master or with full-ci label)
- node-version: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/master' && needs.detect-changes.outputs.has_full_ci_label != 'true' && '20' || '' }}
Expand Down
40 changes: 29 additions & 11 deletions jest.config.base.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
import { createJsWithTsPreset } from 'ts-jest';

const tsconfig = {
// Relative imports in our TS code include `.ts` extensions.
// When compiling the package, TS rewrites them to `.js`,
// but ts-jest runs on the original code where the `.js` files don't exist,
// so this setting needs to be disabled here.
rewriteRelativeImportExtensions: false,
// Override hybrid module kind (Node16/NodeNext) to avoid ts-jest warning
// about requiring isolatedModules: true
module: 'ESNext',
};

const tsJestPreset = createJsWithTsPreset({
tsconfig,
});

// Global Jest configuration for the monorepo
// Contains common settings that all packages inherit
export default {
// === TypeScript Configuration ===
// ts-jest preset with custom TypeScript settings
...createJsWithTsPreset({
tsconfig: {
// Relative imports in our TS code include `.ts` extensions.
// When compiling the package, TS rewrites them to `.js`,
// but ts-jest runs on the original code where the `.js` files don't exist,
// so this setting needs to be disabled here.
rewriteRelativeImportExtensions: false,
},
}),
// ts-jest preset with custom TypeScript settings, extended to handle .cts/.mts files
...tsJestPreset,
transform: {
...tsJestPreset.transform,
// Extend transform to include CommonJS TypeScript (.cts) and ES Module TypeScript (.mts) files
'^.+\\.[cm]?ts$': [
'ts-jest',
{
tsconfig,
},
],
},

// === Test Environment Configuration ===
testEnvironment: 'jsdom',
Expand All @@ -23,5 +40,6 @@ export default {
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],

// === Common Module File Extensions ===
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json'],
// Include cts/mts for CommonJS/ES module TypeScript files
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'cts', 'mts', 'json'],
};
Loading