1.0.1 • Published 8 years ago
mocha-simple-snapshots v1.0.1
Mocha Snapshots
Snapshot/regression testing for using with Mocha, specially without React/Enzyme. Also additionally outputs error with standard chai assertion (gets picked up by WebStorm).
Install it
npm i mocha-simple-snapshots --save
Use it
import { expect } from 'chai';
describe('method', () => {
it('should match snapshot', () => {
// 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-simple-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-simple-snapshotsor
mocha --require mocha-simple-snapshots --update