Skip to content

Commit 2857c71

Browse files
authored
Fix tests by using jest-babel
1 parent ecb240e commit 2857c71

File tree

4 files changed

+6764
-4128
lines changed

4 files changed

+6764
-4128
lines changed

babel.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
presets: [
3+
['@babel/preset-env', { targets: { node: 'current' } }],
4+
'@babel/preset-typescript',
5+
],
6+
};

jest.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
22
module.exports = {
3+
transform: {
4+
"^.+\\.tsx?$": "ts-jest",
5+
"^.+\\.[t|j]sx?$": "babel-jest", // Use Babel for transforming JS and TS files
6+
"^.+\\.mjs$": "jest-transform-stub", // Use the stub to handle ES modules
7+
},
38
preset: 'ts-jest',
49
testEnvironment: 'node',
10+
moduleNameMapper: {
11+
"^octokit$": "<rootDir>/node_modules/octokit/dist-bundle/index.js",
12+
"^@github/dependency-submission-toolkit$": "<rootDir>/node_modules/@github/dependency-submission-toolkit/dist/index.js",
13+
},
14+
extensionsToTreatAsEsm: [".ts"],
15+
transformIgnorePatterns: ["/node_modules/(?!(octokit|\\@github\\/dependency-submission-toolkit)/)"], // Ensure octokit and @github/dependency-submission-toolkit are transformed
16+
globals: {
17+
"ts-jest": {
18+
useESM: true,
19+
},
20+
},
521
};

0 commit comments

Comments
 (0)