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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    0
  • 1.0.0
    1

Package Sidebar

Install

npm i mocha-simple-snapshots

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

58.1 kB

Total Files

19

Last publish

Collaborators

  • fyodorvi