module.exports = { preset: 'ts-jest/presets/default-esm', testEnvironment: 'node', // Tell Jest where to look for source code and tests roots: ['/src', '/tests'], // Explicitly match files in the tests folder testMatch: [ '/tests/**/*.test.ts', '/tests/**/*.spec.ts' ], // Tell Jest to treat .ts files as ESM modules extensionsToTreatAsEsm: ['.ts'], // Fixes the "Cannot find module" error moduleNameMapper: { // If the import starts with . or .. and ends with .js, strip the .js '^(\\.{1,2}/.*)\\.js$': '$1', // Map the library to mock file // This tells Jest to load simple JS file instead of parsing the complex node_module //'^@BridgemanAccessible/ba-auth$': '/tests/__mocks__/ba-auth.js' }, // Configure the transformer to enable ESM support transform: { '^.+\\.tsx?$': [ 'ts-jest', { useESM: true, } ] } };