# @vue/cli-plugin-unit-jest

> unit-jest plugin for vue-cli

Latest version **5.0.9** (published 2025-08-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @vue/cli-plugin-unit-jest
pnpm add @vue/cli-plugin-unit-jest
yarn add @vue/cli-plugin-unit-jest
bun add @vue/cli-plugin-unit-jest
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities; popular repo.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.9 |
| Published | 2025-08-21 |
| First published | 2018-01-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 15.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 29544 |
| Author | Evan You |
| Maintainers | akryum, yyx990803, soda |
| Keywords | vue, cli, unit-jest |

## Links

- npm: https://www.npmjs.com/package/@vue/cli-plugin-unit-jest
- Repository: https://github.com/vuejs/vue-cli
- Homepage: https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/cli-plugin-unit-jest#readme
- Issues: https://github.com/vuejs/vue-cli/issues
- npm.io page: https://npm.io/package/@vue/cli-plugin-unit-jest

## Dependencies (10)

- [jest](https://npm.io/package/jest.md) ^27.1.0
- [deepmerge](https://npm.io/package/deepmerge.md) ^4.2.2
- [babel-jest](https://npm.io/package/babel-jest.md) ^27.1.0
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.12.16
- [@types/jest](https://npm.io/package/@types/jest.md) ^27.0.1
- [jest-serializer-vue](https://npm.io/package/jest-serializer-vue.md) ^2.0.2
- [jest-transform-stub](https://npm.io/package/jest-transform-stub.md) ^2.0.0
- [jest-watch-typeahead](https://npm.io/package/jest-watch-typeahead.md) ^1.0.0
- [@vue/cli-shared-utils](https://npm.io/package/@vue/cli-shared-utils.md) ^5.0.9
- [@babel/plugin-transform-modules-commonjs](https://npm.io/package/@babel/plugin-transform-modules-commonjs.md) ^7.15.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 5.0.9 (latest) — 2025-08-21
- 5.0.6 (next) — 2022-06-16
- 5.0.8 — 2022-07-07
- 5.0.7 — 2022-07-05
- 4.5.19 — 2022-06-28
- 4.5.18 — 2022-06-16
- 5.0.5 — 2022-06-16
- 4.5.17 — 2022-03-23
- 5.0.4 — 2022-03-22
- 4.5.16 — 2022-03-15
- 5.0.3 — 2022-03-15
- 5.0.2 — 2022-03-15
- 5.0.1 — 2022-02-17
- 5.0.0 — 2022-02-17
- 5.0.0-rc.3 — 2022-02-10
- … 145 more at https://npm.io/package/@vue/cli-plugin-unit-jest/versions

## README

# @vue/cli-plugin-unit-jest

> unit-jest plugin for vue-cli

## Injected Commands

- **`vue-cli-service test:unit`**

  Run unit tests with Jest. Default `testMatch` is `<rootDir>/(tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx))` which matches:

  - Any files in `tests/unit` that end in `.spec.(js|jsx|ts|tsx)`;
  - Any js(x)/ts(x) files inside `__tests__` directories.

  Usage: `vue-cli-service test:unit [options] <regexForTestFiles>`

  All [Jest command line options](https://facebook.github.io/jest/docs/en/cli.html) are also supported.

## Debugging Tests

Note that directly running `jest` will fail because the Babel preset requires hints to make your code work in Node.js, so you must run your tests with `vue-cli-service test:unit`.

If you want to debug your tests via the Node inspector, you can run the following:

```bash
# macOS or linux
node --inspect-brk ./node_modules/.bin/vue-cli-service test:unit --runInBand

# Windows
node --inspect-brk ./node_modules/@vue/cli-service/bin/vue-cli-service.js test:unit --runInBand
```

## Configuration

Jest can be configured via `jest.config.js` in your project root, or the `jest` field in `package.json`.

## Installing in an Already Created Project

```bash
vue add unit-jest
```

## Transform dependencies from `/node_modules`

By default, jest doesn't transform anything from `/node_modules`.

Since jest runs in node, we also don't have to transpile anything that uses modern ECMAScript features as Node >=8 already supports these features, so it's a sensible default. cli-plugin-jest also doesn't respect the `transpileDependencies` option in `vue.config.js` for the same reason.

However, we have (at least) three cases where we do need to transpile code from `/node_modules` in jest:

1. Usage of ES6 `import`/`export` statements, which have to be compiled to commonjs `module.exports`
2. Single File Components (`.vue` files) which have to be run through `vue-jest`
3. Typescript code

To do this, we need to add an exception to the `transformIgnorePatterns` option of jest. This is its default value:

```javascript
transformIgnorePatterns: ['/node_modules/']
```

We have to add exceptions to this pattern with a RegExp negative lookahead:

```javascript
transformIgnorePatterns: ['/node_modules/(?!name-of-lib-o-transform)']
```

To exclude multiple libraries:

```javascript
transformIgnorePatterns: ['/node_modules/(?!lib-to-transform|other-lib)']
```

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