Skip to content

Commit 48c0c07

Browse files
committed
refactor(Bun > npm + Jest): Jest runs E2E via Babel (uniform TS/ESM), minimal module mapping, dotenvx for envs
- Switched Bun TS runner to Node + tsx with dotenvx wrapping for env loading. - Replaced Bun E2E runner with Jest using a dedicated jest e2e config - Resolved CJS/ESM breakages by using Babel transfomer for .ts|.js| in Jest. - Avoided duplicated module resolution: ignored `.nx/` and `dist/` in Jest. - Prevented hijacking external `@lit-protocol/*` and only map local packages
1 parent 85bf7ac commit 48c0c07

File tree

4 files changed

+372
-202
lines changed

4 files changed

+372
-202
lines changed

babel.config.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{ "targets": { "node": "current" }, "modules": "commonjs" }
6+
],
7+
["@babel/preset-typescript", { "allowDeclareFields": true }]
8+
]
9+
}

jest.e2e.config.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import type { Config } from 'jest';
2+
3+
// only map local packages (prevent hijacking external `@lit-protocol/*` packages)
4+
const localPackages = [
5+
'access-control-conditions',
6+
'access-control-conditions-schemas',
7+
'auth',
8+
'auth-helpers',
9+
'auth-services',
10+
'constants',
11+
'crypto',
12+
'lit-client',
13+
'logger',
14+
'networks',
15+
'schemas',
16+
'types',
17+
'wasm',
18+
'wrapped-keys',
19+
'wrapped-keys-lit-actions',
20+
];
21+
22+
const config: Config = {
23+
testEnvironment: 'node',
24+
testMatch: ['<rootDir>/e2e/src/e2e.spec.ts'],
25+
26+
// Use Babel for everything; simple and robust with TS + ESM
27+
transform: {
28+
'^.+\\.(ts|tsx|js|mjs)$': 'babel-jest',
29+
},
30+
31+
// Allow transforms for node_modules so ESM deps work
32+
transformIgnorePatterns: [],
33+
34+
// Resolve monorepo packages to sources
35+
moduleNameMapper: {
36+
37+
// Local packages
38+
[`^@lit-protocol/(${localPackages.join('|')})/lib/(.*)$`]:
39+
'<rootDir>/packages/$1/src/lib/$2',
40+
[`^@lit-protocol/(${localPackages.join('|')})(/.*)?$`]:
41+
'<rootDir>/packages/$1/src$2',
42+
},
43+
44+
// this is to avoid duplicate module resolution errors
45+
// eg.
46+
// jest-haste-map: Haste module naming collision: @lit-protocol/crypto
47+
// The following files share their name; please adjust your hasteImpl:
48+
// * <rootDir>/packages/crypto/package.json
49+
// * <rootDir>/.nx/cache/10833129804332267556/outputs/dist/packages/crypto/package.json
50+
// FAIL e2e/src/e2e.spec.ts
51+
// ● Test suite failed to run
52+
// The name `@lit-protocol/auth` was looked up in the Haste module map. It cannot be resolved, because there exists several different files, or packages, that provide a module for that particular name and platform. The platform is generic (no extension). You must delete or exclude files until there remains only one of these:
53+
modulePathIgnorePatterns: ['<rootDir>/.nx/', '<rootDir>/dist/'],
54+
};
55+
56+
export default config;

0 commit comments

Comments
 (0)