Skip to content

Commit 909f435

Browse files
test(js): enable ESM Jest imports & update tests (#119)
Add babel.config.js and install @babel/core and @babel/preset-env so Jest can use ES6 module imports. Update eslint.config.mjs (ecmaVersion: 2022, sourceType: module) for test files. Replace /* eslint-env jest */ with explicit imports from '@jest/globals' (jest, describe, test, expect, beforeEach, afterEach) in multiple tests and testUtils to use ESM Jest globals and satisfy linting.
1 parent 9bf3ef7 commit 909f435

File tree

8 files changed

+42
-5
lines changed

8 files changed

+42
-5
lines changed

babel.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// this allows jest to use ES6 module imports
2+
module.exports = {presets: ['@babel/preset-env']}

eslint.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export default [
2929
files: ["tests/**/*.js"],
3030
...pluginJest.configs['flat/recommended'],
3131
languageOptions: {
32+
ecmaVersion: 2022,
33+
sourceType: "module",
3234
globals: {
3335
...globals.node,
3436
...globals.jest,

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"actions"
1818
],
1919
"devDependencies": {
20+
"@babel/core": "7.29.0",
21+
"@babel/preset-env": "7.29.0",
2022
"@eslint/js": "9.39.2",
2123
"@jest/globals": "30.2.0",
2224
"eslint": "9.39.2",

tests/audit_repos/test_audit.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
* @jest-environment node
44
*/
55

6-
/* eslint-env jest */
6+
import {
7+
jest,
8+
describe,
9+
test,
10+
expect,
11+
beforeEach,
12+
afterEach,
13+
} from '@jest/globals';
714

815
// Mock the GitHub Actions core, context, and GitHub objects
916
const mockCore = {

tests/pinact/test_pinact.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
* @jest-environment node
44
*/
55

6-
/* eslint-env jest */
6+
import {
7+
jest,
8+
describe,
9+
test,
10+
expect,
11+
beforeEach,
12+
afterEach,
13+
} from '@jest/globals';
714

815
const { execSync, execFileSync } = require('node:child_process');
916
const fs = require('node:fs');

tests/release_changelog/test_changelog.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
* @jest-environment node
44
*/
55

6-
/* eslint-env jest */
6+
import {
7+
jest,
8+
describe,
9+
test,
10+
expect,
11+
beforeEach,
12+
afterEach,
13+
} from '@jest/globals';
714

815
const { createMockContext, createMockGithub, createMockCore, setupConsoleMocks, createMockReleases, setupBranchCreationMocks, verifyBranchCreation, setupChangelogWorkflow } = require('../testUtils.js');
916

tests/release_create/test_cleanup.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
* @jest-environment node
44
*/
55

6-
/* eslint-env jest */
6+
import {
7+
jest,
8+
describe,
9+
test,
10+
expect,
11+
beforeEach,
12+
afterEach,
13+
} from '@jest/globals';
714

815
const { createMockContext, createMockGithub, setupConsoleMocks, createMockRelease, createMockReleases, setupDeleteMocks, verifyDeleteCalls, setupCleanupEnv } = require('../testUtils.js');
916

tests/testUtils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
* Shared test utilities for JavaScript tests
33
*/
44

5-
/* eslint-env jest */
5+
import {
6+
jest,
7+
expect,
8+
} from '@jest/globals';
69

710
/**
811
* Create mock GitHub context object

0 commit comments

Comments
 (0)