Skip to content

Commit 522abd7

Browse files
committed
feat(logger): update jest config
1 parent 373e257 commit 522abd7

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

embed/jest.config.ts

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
import type { JestConfigWithTsJest } from "ts-jest";
1+
import { type JestConfigWithTsJest } from "ts-jest";
22

33
const config: JestConfigWithTsJest = {
4-
extensionsToTreatAsEsm: [".ts"],
5-
preset: "ts-jest",
4+
preset: "ts-jest/presets/default-esm",
65
testEnvironment: "node",
76
moduleNameMapper: {
87
"^@gitcoin/passport-identity$": "<rootDir>/../node_modules/@gitcoin/passport-identity/dist/esm/index.js",
98
"^multiformats/(.*)$": "<rootDir>/../node_modules/multiformats/dist/src/$1.js",
109
"^multiformats$": "<rootDir>/../node_modules/multiformats/dist/index.min.js",
1110
"^@ipld/dag-cbor$": "<rootDir>/../node_modules/@ipld/dag-cbor/esm/index.js",
1211
"^uint8arrays(/|$)": "<rootDir>/../node_modules/uint8arrays/dist/index.min.js",
13-
"^(\.\.?/.*)\\.js$": "$1",
12+
"^(..?/.*)\\.js$": "$1",
1413
},
1514
transform: {
16-
"^.+\\.ts$": "ts-jest",
17-
// For transforming the dependencies that aren't playing nicely
18-
"^.+\\.js$": [
15+
"^.+\\.(j|t)s$": [
16+
// Use babel-jest to transpile both local typescript files and
17+
// the dependencies that only available in esm format (dids, etc)
1918
"babel-jest",
2019
{
21-
presets: [["@babel/preset-env", { targets: { node: "current" } }]],
22-
plugins: ["@babel/plugin-transform-modules-commonjs"],
20+
presets: ["@babel/preset-typescript", ["@babel/preset-env", { targets: { node: "current" } }]],
21+
plugins: [
22+
"@babel/plugin-syntax-import-assertions",
23+
"babel-plugin-transform-import-meta",
24+
["babel-plugin-replace-import-extension", { extMapping: { ".js": "" } }],
25+
"@babel/plugin-transform-modules-commonjs",
26+
],
2327
},
2428
],
2529
},

identity/jest.config.ts

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
1-
import type { JestConfigWithTsJest } from "ts-jest";
1+
import { type JestConfigWithTsJest } from "ts-jest";
22

33
const config: JestConfigWithTsJest = {
4+
preset: "ts-jest/presets/default-esm",
5+
testEnvironment: "node",
46
moduleNameMapper: {
57
"^multiformats/(.*)$": "<rootDir>/../node_modules/multiformats/dist/src/$1.js",
68
"^multiformats$": "<rootDir>/../node_modules/multiformats/dist/index.min.js",
79
"^@ipld/dag-cbor$": "<rootDir>/../node_modules/@ipld/dag-cbor/esm/index.js",
810
"^uint8arrays(/|$)": "<rootDir>/../node_modules/uint8arrays/dist/index.min.js",
9-
"^(\\.\\.?/.*)\\.js$": "$1",
11+
"^(..?/.*)\\.js$": "$1",
1012
},
11-
preset: "ts-jest",
12-
testEnvironment: "node",
1313
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)
1617
"babel-jest",
1718
{
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+
],
2026
},
2127
],
2228
},
2329
setupFilesAfterEnv: ["<rootDir>/src/jest.setup.ts"],
2430
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)/)",
2632
],
2733
};
2834

0 commit comments

Comments
 (0)