Skip to content

Commit

Permalink
Actually use ECMAScript modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Oct 28, 2022
1 parent a8b0bcf commit b06b2e1
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 14 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export NODE_OPTIONS := --experimental-vm-modules --redirect-warnings=artifacts/node-warnings

-include .makefiles/Makefile
-include .makefiles/pkg/js/v1/Makefile
-include .makefiles/pkg/js/v1/with-yarn.mk
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@
// jest.config.js
export { default } from "@snout/jest-config";
```

```makefile
# Makefile
export NODE_OPTIONS := --experimental-vm-modules --redirect-warnings=artifacts/node-warnings
```
23 changes: 17 additions & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
export default {
preset: "es-jest",
/** @type {import('jest').Config} */
const config = {
preset: "ts-jest/presets/default-esm",
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
"\\.tsx?$": "ts-jest",
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true,
},
],
},
transformIgnorePatterns: [],
collectCoverageFrom: ["src/**/*"],
testMatch: ["<rootDir>/test/**/*.spec.*"],
resetMocks: true,
collectCoverageFrom: ["<rootDir>/src/**/*"],
coverageDirectory: "artifacts/coverage/jest",
testMatch: ["**/test/unit/**/*.spec.*"],
};

export default config;
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
"jest.config.js"
],
"dependencies": {
"@types/jest": "^29.0.0",
"es-jest": "^2.0.0",
"jest": "^29.0.2",
"ts-jest": "^29.0.1"
"@types/jest": "^29.2.0",
"jest": "^29.2.2",
"ts-jest": "^29.0.3"
},
"devDependencies": {
"@snout/tsconfig": "^2.0.0",
"@snout/tsconfig": "^3.0.0",
"prettier": "^2.7.1",
"typescript": "^4.8.2"
"typescript": "^4.8.4"
}
}
1 change: 1 addition & 0 deletions test/fixture/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const foo = "foo";
6 changes: 4 additions & 2 deletions test/unit/example.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
it("should have a single test for CI to pass", () => {
expect(true).toBe(true);
import { foo } from "../fixture/module.js";

it("should resolve ECMAScript modules", () => {
expect(foo).toBe("foo");
});

0 comments on commit b06b2e1

Please sign in to comment.