@sucrase/jest-plugin

3.0.0 • Public • Published

Sucrase Jest plugin

npm version MIT License

This is a simple Jest plugin that makes it easy to use Sucrase when running Jest tests.

Usage

First install the package and sucrase as a dev dependency:

yarn add --dev @sucrase/jest-plugin sucrase

Then change the default transform in jest.config.js file:

  ...
  transform: { "\\.(js|jsx|ts|tsx)$": "@sucrase/jest-plugin" },
  ...

You can specify additional transformation options to Sucrase by passing an object. For example, to enable automatic react transforms:

  ...
  transform: { "\\.(js|jsx|ts|tsx)$": ["@sucrase/jest-plugin", { jsxRuntime: 'automatic' }] },
  ...

By default, the transforms option is automatically detected based on file type and Jest mode. If you pass a transforms array in the options, it will apply to all files, regardless of extension.

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i @sucrase/jest-plugin

    Weekly Downloads

    21,550

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    11.9 kB

    Total Files

    17

    Last publish

    Collaborators

    • alangpierce