mocha-simple-snapshots

1.0.1 • Public • Published

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

/mocha-simple-snapshots/

    Package Sidebar

    Install

    npm i mocha-simple-snapshots

    Weekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    58.1 kB

    Total Files

    19

    Last publish

    Collaborators

    • fyodorvi