This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

mocha-chai-snapshots

1.0.4 • Public • Published

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

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

Package Sidebar

Install

npm i mocha-chai-snapshots

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

60.6 kB

Total Files

20

Last publish

Collaborators

  • kostenko