flow-aware-swc-jest
v1.2.0
Published
Use @swc/jest even if you have flow
Downloads
1,061
Maintainers
Readme
flow-aware-swc-jest
Use @swc/jest
even if you are using flow.
Installation
npm i --save-dev flow-aware-swc-jest
Configuration
- You need to configure
.swcrc
like below.
{
"jsc": {
"parser": {
"syntax": "typescript",
"jsx": true,
"tsx": true,
"dynamicImport": false,
"privateMethod": false,
"functionBind": false,
"exportDefaultFrom": false,
"exportNamespaceFrom": false,
"decorators": false,
"decoratorsBeforeExport": false,
"topLevelAwait": false,
"importMeta": false,
"preserveAllComments": false
},
"transform": null,
"target": "es5",
"loose": true,
"externalHelpers": false,
"keepClassNames": false
},
"isModule": true
}
- Configure jest config trasform
transform: {
'^.+\\.(t|j)sx?$': 'flow-aware-swc-jest',
},
I have error when jest.spyOn
TypeError: Cannot redefine property
or TypeError: Cannot read properties of undefined
You need to do mock as a esModule
jest.mock("./path_to_spy", () => {
return {
__esModule: true, // <- Important!
...jest.requireActual("./path_to_spy"),
};
});