# @swc/jest

> swc integration for jest

Latest version **0.2.39** (published 2025-07-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @swc/jest
pnpm add @swc/jest
yarn add @swc/jest
bun add @swc/jest
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: has types; no vulnerabilities; high maintenance score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.2.39 |
| Published | 2025-07-09 |
| First published | 2020-09-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 14.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 86 |
| Author | 강동윤 |
| Maintainers | kdy1, kwonoj |

## Links

- npm: https://www.npmjs.com/package/@swc/jest
- Repository: https://github.com/swc-project/pkgs
- Homepage: https://github.com/swc-project/pkgs/tree/main/packages/jest
- Issues: https://github.com/swc-project/pkgs/issues
- npm.io page: https://npm.io/package/@swc/jest

## Dependencies (3)

- [@swc/counter](https://npm.io/package/@swc/counter.md) ^0.1.3
- [jsonc-parser](https://npm.io/package/jsonc-parser.md) ^3.2.0
- [@jest/create-cache-key-function](https://npm.io/package/@jest/create-cache-key-function.md) ^30.0.0

## Recent versions

- 0.2.39 (latest) — 2025-07-09
- 0.2.38 — 2025-04-23
- 0.2.37 — 2024-10-30
- 0.2.36 — 2024-02-05
- 0.2.34 — 2024-02-01
- 0.2.33 — 2024-02-01
- 0.2.32 — 2024-02-01
- 0.2.31 — 2024-01-20
- 0.2.30 — 2024-01-18
- 0.2.29 — 2023-08-12
- 0.2.28 — 2023-08-06
- 0.2.27 — 2023-07-20
- 0.2.26 — 2023-04-14
- 0.2.25 — 2023-04-14
- 0.2.24 — 2022-12-10
- … 27 more at https://npm.io/package/@swc/jest/versions

## README

# @swc/jest

[SWC][] binding for Jest.

## Installation

```sh
# if you use npm
npm i -D jest @swc/core @swc/jest
# if you use yarn
yarn add -D jest @swc/core @swc/jest
```

## Usage

`jest.config.js`:

```js
module.exports = {
  transform: {
    '^.+\\.(t|j)sx?$': '@swc/jest',
  },
}
```

It will load the SWC configuration from `.swcrc` by default. You also can customize it:

```js
const fs = require('fs')

const config = JSON.parse(fs.readFileSync(`${__dirname}/.swcrc`, 'utf-8'))

module.exports = {
  transform: {
    '^.+\\.(t|j)sx?$': ['@swc/jest', { ...config, /* custom configuration in Jest */ }],
  },
}
```

## Q & A

### Q: Jest uses CommonJS by default. But I want to use ESM.

A: Setup Jest following this [Guide](https://jestjs.io/docs/ecmascript-modules).

  For JavaScript, edit `package.json` as follows:
  
  ```json
  {
    // ...
    "type": "module"
  }
  ```

  For TypeScript, edit `jest.config.js` as follows:

  ```js
  module.exports = {
    // ...
    extensionsToTreatAsEsm: ['.ts', '.tsx'],
  }
  ```

  Run test with `--experimental-vm-modules`:

  ```sh
  cross-env NODE_OPTIONS=--experimental-vm-modules jest

  # or
  node --experimental-vm-modules ./node_modules/jest/bin/jest.js
  ```

### Q: What ECMAScript target is set by `jsc.target`?

A: By default, the version supported by your Node runtime.

| Node version | Default `jsc.target` |
|--------------|----------------------|
| 12           | 'es2018'             |
| 13           | 'es2019'             |
| 14           | 'es2020'             |
| 15           | 'es2021'             |
| 16           | 'es2021'             |
| 17           | 'es2022'             |
| 18           | 'es2023'             |
| 19           | 'es2023'             |
| 20           | 'es2023'             |

You can customize this by setting an explicit version in `jest.config.js`:

```js
module.exports = {
    transform: {
        "^.+\\.(t|j)sx?$": [
            "@swc/jest",
            {
                jsc: {
                    target: "es2021",
                },
            },
        ],
    },
}
```

## License

MIT

[SWC]: https://swc.rs

---
_Source: https://npm.io/package/@swc/jest · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
