Skip to content

Commit f96ae64

Browse files
e-conomic-ai[bot]dependabot[bot]ecoai-botmikkelguntveit
authored
EC-76387: [Alternative] Fix ESM compatibility with simpler mocking approach (#1215)
* Bump @actions/core from 2.0.3 to 3.0.0 Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 2.0.3 to 3.0.0. - [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core) --- updated-dependencies: - dependency-name: "@actions/core" dependency-version: 3.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * EC-76387: Fix ESM compatibility with simpler mocking approach The @actions/core v3.0.0 upgrade introduces ESM-only modules which breaks Jest tests. This PR uses a simpler approach than jest.unstable_mockModule: - Creates simple fake objects instead of module-level mocking - Uses helper functions for cleaner, more readable tests - Still requires Jest ESM configuration changes Changes: - Updated Jest config to support ESM modules - Added --experimental-vm-modules flag to npm test script - Refactored eventService.test.ts to use simple fake objects Co-Authored-By: Mikkel Sander Guntveit <mikkel.guntveit@visma.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: ecoai-bot <ecoai-bot@e-conomic.com> Co-authored-by: Mikkel Sander Guntveit <mikkel.guntveit@visma.com>
1 parent 4ef04be commit f96ae64

4 files changed

Lines changed: 184 additions & 315 deletions

File tree

jest.config.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ module.exports = {
22
preset: 'ts-jest',
33
testEnvironment: 'node',
44
transform: {
5-
'^.+\\.js?$': 'babel-jest'
5+
'^.+\\.tsx?$': ['ts-jest', {
6+
useESM: true
7+
}],
8+
'^.+\\.jsx?$': 'babel-jest'
69
},
7-
transformIgnorePatterns: ['node_modules/(?!@library)/']
10+
transformIgnorePatterns: ['node_modules/(?!@actions)/'],
11+
extensionsToTreatAsEsm: ['.ts'],
12+
moduleNameMapper: {
13+
'^(\\.{1,2}/.*)\\.js$': '$1'
14+
}
815
}

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"lint:fix": "npm run lint -- --fix",
1414
"package": "npm run clean:package && npm run build && npm run package:single",
1515
"package:single": "ncc build --out dist --minify --source-map --v8-cache",
16-
"test": "jest",
16+
"test": "NODE_OPTIONS='--experimental-vm-modules' jest",
1717
"test:ci": "npm run test -- --ci",
1818
"test:coverage": "npm run test -- --collect-coverage",
1919
"test:watch": "npm run test:coverage -- --watch --verbose false",
@@ -36,7 +36,7 @@
3636
},
3737
"homepage": "https://github.com/e-conomic/mergebot#readme",
3838
"dependencies": {
39-
"@actions/core": "2.0.3",
39+
"@actions/core": "3.0.0",
4040
"@actions/github": "9.0.0",
4141
"@octokit/auth-app": "7.1.4",
4242
"@octokit/rest": "21.1.0",

0 commit comments

Comments
 (0)