Skip to content

Commit b8cc659

Browse files
committed
fix: update fuzz testing to use ES modules with Jest
- Convert fuzz.test.js to fuzz.test.mjs with ES module imports - Add Jest configuration to handle ES modules properly - Use import statements instead of require() for compatibility - Configure Jest to treat .mjs files as ES modules
1 parent 95e8d9d commit b8cc659

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ jobs:
9393
9494
- name: Run fuzz tests
9595
run: |
96-
cat << 'EOF' > fuzz.test.js
97-
const fc = require('fast-check');
98-
const utils = require('./dist/utils.js');
96+
cat << 'EOF' > fuzz.test.mjs
97+
import fc from 'fast-check';
98+
import * as utils from './dist/utils.js';
9999
100100
describe('Fuzz Testing', () => {
101101
test('detectPackageManager handles arbitrary strings', () => {
@@ -133,4 +133,20 @@ jobs:
133133
});
134134
});
135135
EOF
136-
npx jest fuzz.test.js --testTimeout=30000
136+
137+
cat << 'EOF' > jest.config.js
138+
export default {
139+
preset: 'default',
140+
extensionsToTreatAsEsm: ['.mjs'],
141+
globals: {
142+
'ts-jest': {
143+
useESM: true
144+
}
145+
},
146+
transform: {},
147+
testMatch: ['**/*.test.mjs'],
148+
testTimeout: 30000
149+
};
150+
EOF
151+
152+
npx jest fuzz.test.mjs

0 commit comments

Comments
 (0)