|
1 |
| -import type { JestConfigWithTsJest } from "ts-jest"; |
| 1 | +import { type JestConfigWithTsJest } from "ts-jest"; |
2 | 2 |
|
3 | 3 | const config: JestConfigWithTsJest = {
|
| 4 | + preset: "ts-jest/presets/default-esm", |
| 5 | + testEnvironment: "node", |
4 | 6 | moduleNameMapper: {
|
5 | 7 | "^multiformats/(.*)$": "<rootDir>/../node_modules/multiformats/dist/src/$1.js",
|
6 | 8 | "^multiformats$": "<rootDir>/../node_modules/multiformats/dist/index.min.js",
|
7 | 9 | "^@ipld/dag-cbor$": "<rootDir>/../node_modules/@ipld/dag-cbor/esm/index.js",
|
8 | 10 | "^uint8arrays(/|$)": "<rootDir>/../node_modules/uint8arrays/dist/index.min.js",
|
9 |
| - "^(\\.\\.?/.*)\\.js$": "$1", |
| 11 | + "^(..?/.*)\\.js$": "$1", |
10 | 12 | },
|
11 |
| - preset: "ts-jest", |
12 |
| - testEnvironment: "node", |
13 | 13 | transform: {
|
14 |
| - "^.+\\.tsx?$": ["ts-jest", {}], |
15 |
| - "^.+\\.js$": [ |
| 14 | + "^.+\\.(j|t)s$": [ |
| 15 | + // Use babel-jest to transpile both local typescript files and |
| 16 | + // the dependencies that only available in esm format (dids, etc) |
16 | 17 | "babel-jest",
|
17 | 18 | {
|
18 |
| - presets: [["@babel/preset-env", { targets: { node: "current" } }]], |
19 |
| - plugins: ["@babel/plugin-transform-modules-commonjs"], |
| 19 | + presets: ["@babel/preset-typescript", ["@babel/preset-env", { targets: { node: "current" } }]], |
| 20 | + plugins: [ |
| 21 | + "@babel/plugin-syntax-import-assertions", |
| 22 | + "babel-plugin-transform-import-meta", |
| 23 | + ["babel-plugin-replace-import-extension", { extMapping: { ".js": "" } }], |
| 24 | + "@babel/plugin-transform-modules-commonjs", |
| 25 | + ], |
20 | 26 | },
|
21 | 27 | ],
|
22 | 28 | },
|
23 | 29 | setupFilesAfterEnv: ["<rootDir>/src/jest.setup.ts"],
|
24 | 30 | transformIgnorePatterns: [
|
25 |
| - "/node_modules/(?!(dids|dag-jose-utils|multiformats|@ipld|rpc-utils|@didtools|codeco|uint8arrays|key-did-resolver)/)", |
| 31 | + "/node_modules/(?!(dids|dag-jose-utils|multiformats|@ipld|rpc-utils|@didtools|codeco|key-did-resolver)/)", |
26 | 32 | ],
|
27 | 33 | };
|
28 | 34 |
|
|
0 commit comments