# mocha-chai-snapshots

> Snapshot testing for Mocha + Chai users

Latest version **1.0.4** (published 2019-05-09) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install mocha-chai-snapshots
pnpm add mocha-chai-snapshots
yarn add mocha-chai-snapshots
bun add mocha-chai-snapshots
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2019-05-09 |
| First published | 2019-05-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 59.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Andrii Kostenko |
| Maintainers | kostenko |
| Keywords | mocha, chai, snapshot, regression, test, testing |

## Links

- npm: https://www.npmjs.com/package/mocha-chai-snapshots
- Repository: https://github.com/Short-cm/chai-snapshots
- Homepage: https://github.com/Short-cm/chai-snapshots#readme
- Issues: https://github.com/Short-cm/chai-snapshots/issues
- npm.io page: https://npm.io/package/mocha-chai-snapshots

## Dependencies (4)

- [diff](https://npm.io/package/diff.md) ^3.5.0
- [colors](https://npm.io/package/colors.md) ^1.3.3
- [pretty-format](https://npm.io/package/pretty-format.md) ^24.8.0
- [enzyme-to-json](https://npm.io/package/enzyme-to-json.md) ^3.3.5

## 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.0.4 (latest) — 2019-05-09
- 1.0.3 — 2019-05-09
- 1.0.2 — 2019-05-09
- 1.0.1 — 2019-05-09
- 1.0.0 — 2019-05-09

## README

# Mocha/Chai Snapshots

Snapshot/regression testing for using with Chai, specially for React+Enzyme users.

**Based on mocha-snapshot https://github.com/wellguimaraes/mocha-snapshots**

It has incompatible difference - it uses `pretty-format` instead of JSON.

See https://www.npmjs.com/package/pretty-format documentation for serialization format

## Install it
`npm i mocha-chai-snapshots --save-dev`

## Use it
```es6
import { expect } from 'chai';
import { shallow } from 'enzyme';
import MyComponent from './path/to/MyComponent';

describe('<MyComponent />', () => {
  it('should match snapshot', () => {
    const wrapper = shallow(<MyComponent />)
    
    // You can match Enzyme wrappers
    expect(wrapper).to.matchSnapshot();
    
    // Strings
    expect('you can match strings').to.matchSnapshot();
    
    // Numbers
    expect(123).to.matchSnapshot();
    
    // Or any object
    expect({ a: 1, b: { c: 1 } }).to.matchSnapshot();
   
  });
});
```

## Run your tests
Add a require argument to your test script/command 

`mocha --require mocha-chai-snapshots`

## Update snapshots
Set an environment variable `UPDATE` and run your test script or add the flag `--update`  when running Mocha:

```
UPDATE=1 mocha --require mocha-chai-snapshots
``` 
or
```
mocha --require mocha-chai-snapshots --update
```

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