There is a simple question I cannot find an answer to. When using:
- Node 17 + Typescript
- ESM ("type": "module" in package.json)
Can I implement mock for one function only? or module?
If so, can I get an example? No matter what framework you use.
thanks!!
package.json:
{
"test": "node --experimental-vm-modules ./node_modules/.bin/jest --bail --colors --coverage --detectOpenHandles --forceExit --verbose",
"jest": {
"preset": "ts-jest/presets/default-esm",
"transform": {
".ts": "ts-jest"
},
"testEnvironment": "node",
"moduleFileExtensions": [
"ts",
"js",
"json"
],
"transformIgnorePatterns": [
"<rootDir>/node_modules/"
],
"globals": {
"ts-jest": {
"useESM": true
}
}
}
}
Jest.spy gives me an error: cannot assign to read-only property I tried using Sinon too, and I got: es modules cannot be stubbed