@sucrase/jest-plugin

Jest plugin for Sucrase

Usage no npm install needed!

<script type="module">
  import sucraseJestPlugin from 'https://cdn.skypack.dev/@sucrase/jest-plugin';
</script>

README

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 as a dev dependency:

yarn add --dev @sucrase/jest-plugin

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

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

Currently, the transforms are not configurable; it uses always runs the import and jest transforms and uses the file extension to decide whether to run the JSX, Flow, and/or TypeScript transforms.