Skip to content

Commit c33853e

Browse files
authored
Maintenance: Updated NPM packages (#6090)
* Maintenance: Updated NPM packages Includes typescript update to 6. Needed to update some typescript config to align with actual module environment used and built by esbuild. * Maintenance: Fixed testing issues after NPM dep version changes * Maintenance: Updated JS test workflow step version * Maintenance: Updated approach used for TS config in jest config
1 parent e033578 commit c33853e

File tree

5 files changed

+720
-614
lines changed

5 files changed

+720
-614
lines changed

.github/workflows/test-js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
if: ${{ github.ref != 'refs/heads/l10n_development' }}
1818
runs-on: ubuntu-24.04
1919
steps:
20-
- uses: actions/checkout@v4
20+
- uses: actions/checkout@v6
2121

2222
- name: Install NPM deps
2323
run: npm ci

jest.config.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55

66
import type {Config} from 'jest';
77
import {pathsToModuleNameMapper} from "ts-jest";
8-
import { compilerOptions } from './tsconfig.json';
8+
import fs from "node:fs";
9+
10+
const { compilerOptions } = JSON.parse(fs.readFileSync('./tsconfig.json', 'utf8'));
11+
const compilerPaths = compilerOptions.paths as Record<string, string[]>;
12+
const cleanedPaths: Record<string, string[]> = {};
13+
Object.keys(compilerPaths).forEach((key) => {
14+
const paths = compilerPaths[key];
15+
cleanedPaths[key] = paths.map(p => p.replace('./', ''));
16+
});
917

1018
const config: Config = {
1119
// All imported modules in your tests should be mocked automatically
@@ -98,7 +106,7 @@ const config: Config = {
98106
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
99107
moduleNameMapper: {
100108
'lexical/shared/invariant': 'resources/js/wysiwyg/lexical/core/shared/__mocks__/invariant',
101-
...pathsToModuleNameMapper(compilerOptions.paths),
109+
...pathsToModuleNameMapper(cleanedPaths),
102110
},
103111

104112
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
@@ -111,7 +119,7 @@ const config: Config = {
111119
// notifyMode: "failure-change",
112120

113121
// A preset that is used as a base for Jest's configuration
114-
// preset: undefined,
122+
preset: 'ts-jest',
115123

116124
// Run tests from one or more projects
117125
// projects: undefined,

0 commit comments

Comments
 (0)