mocha-jest-snapshots
Snapshot testing for Mocha users
Last updated a year ago by tomitrescak .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mocha-jest-snapshots 
SYNC missed versions from official npm registry.

Mocha Snapshots

FORKED from https://github.com/wellguimaraes/mocha-snapshots

Snapshot/regression testing for using with Mocha.

  • Works with and without Enzyme
  • Works with React Test Renderer
  • Plugin replacement from jest snapshots

Install it

npm i mocha-jest-snapshots --save

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-jest-snapshots

Disable classNames cleanup

To prevent false mismatches, mocha-jest-snapshots sanitizes className props by default. You can disable this behavior before running your tests:

import mochaSnapshots from 'mocha-jest-snapshots';

mochaSnapshots.setup({ sanitizeClassNames: false });

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-jest-snapshots

or

mocha --require mocha-jest-snapshots --update

Current Tags

  • 1.0.7                                ...           latest (a year ago)

1 Versions

  • 1.0.7                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (2)
Dev Dependencies (11)

Copyright 2014 - 2016 © taobao.org |