Skip to content

Commit 3fe2ad1

Browse files
committed
fix: disable vitest interopDefault for native CJS resolution
Set deps.interopDefault: false so vitest matches Node's native ESM-CJS interop behavior. Fix fast-glob import that relied on vitest auto-unwrapping the CJS default export.
1 parent 0a342c8 commit 3fe2ad1

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

.config/vitest.config.isolated.mts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ const isCoverageEnabled =
3333

3434
export default defineConfig({
3535
test: {
36+
deps: {
37+
interopDefault: false,
38+
},
3639
globals: false,
3740
environment: 'node',
3841
include: ['test/**/*.test.{js,ts,mjs,mts,cjs}'],

.config/vitest.config.mts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ if (isCoverageEnabled) {
3838
export default defineConfig({
3939
cacheDir: './.cache/vitest',
4040
test: {
41+
deps: {
42+
interopDefault: false,
43+
},
4144
globals: false,
4245
environment: 'node',
4346
include: ['test/**/*.test.mts'],

test/purl-spec.test.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ SOFTWARE.
2828
*/
2929
import path from 'node:path'
3030

31-
import { glob } from 'fast-glob'
31+
import fastGlob from 'fast-glob'
3232
import { describe, expect, it } from 'vitest'
3333

3434
import { readJson } from '@socketsecurity/lib/fs'
@@ -54,7 +54,7 @@ describe('PackageURL purl-spec test suite', async () => {
5454
// Tests from the official purl-spec test suite (data/*.json files)
5555
const settled = await Promise.allSettled(
5656
(
57-
await glob(['**/**.json'], {
57+
await fastGlob.glob(['**/**.json'], {
5858
absolute: true,
5959
cwd: path.join(__dirname, 'data'),
6060
})

0 commit comments

Comments
 (0)