Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mocha-snapshots

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mocha-snapshots

Snapshot testing for Mocha users

  • 2.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2K
decreased by-43.74%
Maintainers
1
Weekly downloads
 
Created
Source

Mocha Snapshots

Snapshot/regression testing for using with Mocha, specially for React+Enzyme users.

* Jest is cool but too slow!

Install it

npm i mocha-snapshots --save

Use it

import { expect } from 'chai';
import { shallow } from 'enzyme';
import MyComponent from './path/to/MyComponent';

describe('<MyComponent />', () => {
  it('should match snapshot', function() { // Arrow functions are not allowed here
    const wrapper = shallow(<MyComponent />)
    expect(wrapper).to.matchSnapshot();
    expect('you can match strings').to.matchSnapshot();
    expect(123).to.matchSnapshot(); // numbers too
    expect({ a: 1, b: { c: 1 } }).to.matchSnapshot(); // or any object
  });
});

Run your tests

Add a require argument to your test script/command

mocha --require mocha-snapshots

Update snapshots

Set an environment variable UPDATE and run your test script:

ex: UPDATE=1 npm test

Keywords

FAQs

Package last updated on 12 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc