Detalhes do pacote

mocha-simple-snapshots

wellguimaraes13MIT1.0.1

Snapshot testing for Mocha users (without enzyme)

mocha, snapshot, regression, test

readme (leia-me)

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

or

mocha --require mocha-simple-snapshots --update