-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathjest.preset.js
32 lines (30 loc) · 1.13 KB
/
jest.preset.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const nxPreset = require('@nx/jest/preset').default;
const path = require('path');
// List of packages that use ES modules and need to be transformed
const esmModules = [
'@simplewebauthn',
'@coinbase/wallet-sdk',
'@dynamic-labs',
'@safe-global',
'@abstract-foundation',
'@privy-io'
];
module.exports = {
...nxPreset,
// Properly handle both ES modules and CommonJS
transformIgnorePatterns: [
"node_modules/(?!(.pnpm/)?((@simplewebauthn\\/browser|@simplewebauthn|@coinbase\\/wallet-sdk|@dynamic-labs|@safe-global|@abstract-foundation|@privy-io)/)|(.pnpm/@coinbase\\[email protected])|(.pnpm/@simplewebauthn\\[email protected]))"
],
transform: {
'^.+\\.(ts|js|html)$': ['@swc/jest'],
'^.+\\.m?js$': path.join(__dirname, 'jest-config/esm-transformer.js'),
},
moduleNameMapper: {
// Mock problematic ESM modules
'^@simplewebauthn/browser$': path.join(__dirname, 'jest-config/mocks/simplewebauthn-browser.js'),
'^@coinbase/wallet-sdk$': path.join(__dirname, 'jest-config/mocks/coinbase-wallet-sdk.js')
},
// Ensure Jest knows to handle ESM
extensionsToTreatAsEsm: ['.ts', '.tsx'],
testEnvironment: 'node',
};