Socket
Socket
Sign inDemoInstall

flow-aware-swc-jest

Package Overview
Dependencies
4
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

flow-aware-swc-jest

Use @swc/jest even if you have flow


Version published
Weekly downloads
991
decreased by-12.92%
Maintainers
1
Install size
4.43 kB
Created
Weekly downloads
 

Readme

Source

flow-aware-swc-jest

Use @swc/jest even if you are using flow.

babel-jest (61s)flow-aware-swc-jest (23s)
Screenshot 2024-02-09 at 1 30 58 AM Screenshot 2024-02-09 at 1 27 52 AM

Installation

npm i --save-dev flow-aware-swc-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?$': '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"),
  };
});

Keywords

FAQs

Last updated on 26 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc