# mocha-chai-jest-snapshot

> provides snapshot testing like jest

Latest version **1.1.8** (published 2026-10-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install mocha-chai-jest-snapshot
pnpm add mocha-chai-jest-snapshot
yarn add mocha-chai-jest-snapshot
bun add mocha-chai-jest-snapshot
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.1.8 |
| Published | 2026-10-11 |
| First published | 2019-10-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 66.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 33 |
| Author | Yukimasa Funaoka |
| Maintainers | mochiya98 |
| Keywords | mocha, chai, assertion, helper, jest, snapshot, react, test, spec, testing |

## Links

- npm: https://www.npmjs.com/package/mocha-chai-jest-snapshot
- Repository: https://github.com/mochiya98/mocha-chai-jest-snapshot
- Homepage: https://github.com/mochiya98/mocha-chai-jest-snapshot#readme
- Issues: https://github.com/mochiya98/mocha-chai-jest-snapshot/issues
- npm.io page: https://npm.io/package/mocha-chai-jest-snapshot

## Dependencies (6)

- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [slash](https://npm.io/package/slash.md) ^3.0.0
- [jest-util](https://npm.io/package/jest-util.md) ^30.0.5
- [jest-snapshot](https://npm.io/package/jest-snapshot.md) ^30.0.0
- [@jest/test-result](https://npm.io/package/@jest/test-result.md) ^30.0.5
- [find-package-json](https://npm.io/package/find-package-json.md) ^1.2.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 1.1.8 (latest) — 2026-10-11
- 1.1.7 — 2025-08-17
- 1.1.6 — 2024-09-01
- 1.1.5 — 2024-08-24
- 1.1.4 — 2022-06-11
- 1.1.3 — 2021-08-14
- 1.1.2 — 2021-05-15
- 1.1.1 — 2020-10-11
- 1.1.0 — 2020-08-28
- 1.0.2 — 2020-08-10
- 1.0.1 — 2019-10-17
- 1.0.0 — 2019-10-17

## README

# 🍵mocha-chai-jest-snapshot📷

![npm](https://img.shields.io/npm/v/mocha-chai-jest-snapshot?style=flat-square) ![MIT](https://img.shields.io/npm/l/mocha-chai-jest-snapshot?style=flat-square)

[![NPM](https://nodei.co/npm/mocha-chai-jest-snapshot.png)](https://nodei.co/npm/mocha-chai-jest-snapshot/)

provides snapshot testing like jest

## Features

- ✅ Simple to use
- ✅ Output the same snapshot file as jest
- ✅ Output the same snapshot summary as jest
- ✅ Detect obsolete snapshots
- ✅ Support custom serializer
- ✅ Support typescript

## Usage

```bash
npm i -D mocha-chai-jest-snapshot
```

then add it to the test setup:

```js
// e.g. setup.js (mocha --file setup.js)
const chai = require("chai");
const { jestSnapshotPlugin } = require("mocha-chai-jest-snapshot");

chai.use(jestSnapshotPlugin());
```

enjoy.

```js
const { expect } = require("chai");
it("foo", function () {
  expect({ foo: "bar" }).toMatchSnapshot();
});
```

```
> chai-snapshot@1.0.0 test /mnt/x/chai-snapshot
> npx mocha --file setup.js -r ts-node/register test/**/*.ts


  ✓ foo

Snapshot Summary
 › 1 snapshot written from 1 test suite.

  1 passing (9ms)
```

```js
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`foo 1`] = `
Object {
  "foo": "bar",
}
`;
```

### update snapshots

```bash
# set envoriment
UPDATE_SNAPSHOT=1 mocha ...
# or add command line argument
mocha ... --update
```

### report at the end

```bash
npx mocha ... --reporter mocha-chai-jest-snapshot/reporters/spec
```

### with options

#### jest options (setup)

```js
const chai = require("chai");
const { jestSnapshotPlugin } = require("mocha-chai-jest-snapshot");

chai.use(
  jestSnapshotPlugin({
    rootDir: "../",
    snapshotResolver: "<rootDir>/jest/snapshotResolver",
    snapshotSerializers: ["jest-serializer-vue"],
  }),
);
```

#### jest options (package.json)

```json
{
  "jest": {
    "rootDir": "../",
    "snapshotResolver": "<rootDir>/jest/snapshotResolver",
    "snapshotSerializers": ["jest-serializer-vue"]
  }
}
```

#### jest options (jest.config.js)

```js
module.exports = {
  rootDir: "../",
  snapshotResolver: "<rootDir>/jest/snapshotResolver",
  snapshotSerializers: ["jest-serializer-vue"],
};
```

#### custom serializer

```js
const chai = require("chai");
const {
  jestSnapshotPlugin,
  addSerializer,
} = require("mocha-chai-jest-snapshot");
const customSerializer = require("...");

chai.use(jestSnapshotPlugin());
addSerializer(customSerializer);
```

or

```js
const { expect } = require("chai");
const customSerializer = require("...");

expect.addSnapshotSerializer(customSerializer);
```

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