Skip to content

Commit 54dce39

Browse files
committed
chore: update jest config and tests for esm
1 parent 23d3a52 commit 54dce39

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

jest.config.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
export default {
2+
extensionsToTreatAsEsm: ['.ts'],
23
testMatch: ["**/*.test.ts"],
34
transform: {
4-
"^.+\\.tsx?$": "ts-jest",
5+
"^.+\\.tsx?$": [
6+
"ts-jest",
7+
{
8+
useESM: true,
9+
},
10+
],
511
},
612
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"scripts": {
1111
"build": "./build.sh && tsc",
1212
"watch": "tsc -w",
13-
"test": "jest",
13+
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
1414
"lint": "eslint .",
1515
"lint:fix": "eslint --fix .",
1616
"prepare": "npm run build && husky",

src/index.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import "jest-cdk-snapshot"
66
import * as path from "path"
77
import { WebappDeploy } from "."
88
import { Source } from "./source"
9+
import { fileURLToPath } from "url"
10+
11+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
912

1013
test("WebappDeploy", () => {
1114
const app = new cdk.App()

0 commit comments

Comments
 (0)