diff --git a/jest.config.cjs.ts b/jest.config.cjs.ts new file mode 100644 index 0000000..a441dec --- /dev/null +++ b/jest.config.cjs.ts @@ -0,0 +1,23 @@ +import type { Config } from '@jest/types' + +// see https://jestjs.io/docs/ecmascript-modules + +// Sync object +const config: Config.InitialOptions = { + verbose: true, + testMatch: [ + '**/__tests__/**/*.+(ts|tsx|js)', + '**/?(*.)+(spec|test).+(ts|tsx|js)', + ], + moduleDirectories: [ + 'node_modules', + 'src', + ], + moduleFileExtensions: ['ts', 'js'], + extensionsToTreatAsEsm: ['.ts'], + transform: { + '^.+\\.ts$': 'ts-jest', + }, +} + +export default config diff --git a/jest.config.ts b/jest.config.esm.ts similarity index 100% rename from jest.config.ts rename to jest.config.esm.ts diff --git a/package.json b/package.json index 6ef8d1f..5785364 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "bugs": "https://github.com/iconify/collections-json/issues", "scripts": { "build": "rimraf dist && tsup src/index.ts --format cjs,esm --dts", - "test": "yarn build && jest --clearCache && cross-env NODE_OPTIONS=--experimental-vm-modules npx jest" + "test-esm": "yarn build && jest --clearCache && cross-env NODE_OPTIONS=--experimental-vm-modules npx jest --config=jest.config.esm.ts", + "test-cjs": "yarn build && jest --clearCache && jest --config=jest.config.cjs.ts" }, "dependencies": { "upath": "^2.0.1" diff --git a/src/locate.test.ts b/src/locate.test.ts index 38df4b9..fbc223a 100644 --- a/src/locate.test.ts +++ b/src/locate.test.ts @@ -6,7 +6,7 @@ const cwd = process.cwd() describe('locate', () => { test('mdi resolves the json collection', () => { const received = locate('mdi') as string - const expected = resolve(cwd, 'json/', 'mdi.json').replace(/\\/g, '/') + const expected = resolve(cwd, 'json', 'mdi.json').replace(/\\/g, '/') expect(received).toBe(expected) }) })