Open recklyss opened 3 years ago
There seems to be an issue with the package, but for ESM support in Jest this is what I've been able to piece together:
npm install --save-dev jest@next ts-jest@next
ts-jest
with ESM supportNODE_OPTIONS=--experimental-vm-modules
@pacote/jest-either/lib
instead of just @pacote/jest-either
(this is the part that needs to be fixed)package.json
{
"scripts": {
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
},
"jest": {
"preset": "ts-jest/presets/default-esm",
"globals": {
"ts-jest": {
"useESM": true
}
},
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
}
},
"devDependencies": {
"@pacote/jest-either": "^5.0.0",
"fp-ts": "^2.11.5",
"jest": "^27.0.0-next.11",
"ts-jest": "^27.0.0-next.12",
"typescript": "^4.5.4"
}
}
test.ts
import { right } from 'fp-ts/Either'
import matchers from '@pacote/jest-either/lib'
expect.extend(matchers)
test("sanity", () => {
expect(right('ok')).toEqualRight('ok')
})
tsconfig.json
{
"compilerOptions": {
"moduleResolution": "node"
}
}
Hope this helps.
What
When I upgrade
@pacote/jest-either
from4.0.9
to5.0.0
, got error when running test:ENV
Code
I tried some solutions searched from StackOverflow, didn't solve the problem, can anyone help with it?
Tried: modify
modulePaths
ormoduleDirectories
, didn't work...