1.0.2 • Published 1 year ago

react-native-fast-jest v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-native-fast-jest

Run testing 3x faster than babel-jest!

Internally using @swc/jest

Installation

npm i --save-dev react-native-fast-jest

Configuration

  1. 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
}
  1. Configure jest config trasform
transform: {
  '^.+\\.(t|j)sx?$': 'react-native-fast-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'),
    };
});
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago