All Projects → wellguimaraes → mocha-snapshots

wellguimaraes / mocha-snapshots

Licence: MIT License
Snapshot/regression testing for using with Mocha, specially for React+Enzyme users.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to mocha-snapshots

Should Enzyme
Useful functions for testing React Components with Enzyme.
Stars: ✭ 41 (-22.64%)
Mutual labels:  mocha, enzyme
Jobsort
job board that queries hacker news who is hiring job listings from a database and sorts by tech the user knows and how well the user knows them
Stars: ✭ 20 (-62.26%)
Mutual labels:  mocha, enzyme
React Hot Redux Firebase Starter
🌋 React + Redux + Firebase + Webpack + React Hot Loader 3 + React Router in one boilerplate
Stars: ✭ 375 (+607.55%)
Mutual labels:  mocha, enzyme
react-testing-mocha-chai-enzyme
A solid test setup for React components with Mocha, Chai, Sinon, Enzyme in a Webpack/Babel application.
Stars: ✭ 48 (-9.43%)
Mutual labels:  mocha, enzyme
react-native-unit-tests
Example how to test React Native components
Stars: ✭ 79 (+49.06%)
Mutual labels:  mocha, enzyme
React Base
atSistemas React/Redux Isomorphic Platform
Stars: ✭ 82 (+54.72%)
Mutual labels:  mocha, enzyme
Enzyme
JavaScript Testing utilities for React
Stars: ✭ 19,781 (+37222.64%)
Mutual labels:  mocha, enzyme
React Redux Universal Boilerplate
An Universal ReactJS/Redux Boilerplate
Stars: ✭ 165 (+211.32%)
Mutual labels:  mocha, enzyme
js-stack-from-scratch
🌺 Russian translation of "JavaScript Stack from Scratch" from the React-Theming developers https://github.com/sm-react/react-theming
Stars: ✭ 394 (+643.4%)
Mutual labels:  mocha, enzyme
react-multi-context
Manage multiple React 16 contexts with a single component.
Stars: ✭ 19 (-64.15%)
Mutual labels:  mocha, enzyme
react16-seed-with-apollo-graphql-scss-router4-ssr-tests-eslint-prettier-docker-webpack3-hot
Seed to create your own project using React with Apollo GraphQL client
Stars: ✭ 19 (-64.15%)
Mutual labels:  mocha
react-innertext
Returns the innerText of a React JSX object.
Stars: ✭ 37 (-30.19%)
Mutual labels:  mocha
jest-wrap
Fluent pluggable interface for easily wrapping `describe` and `it` blocks in Jest tests.
Stars: ✭ 35 (-33.96%)
Mutual labels:  mocha
awesome-javascript-testing
🔧 Awesome JavaScript testing resources
Stars: ✭ 28 (-47.17%)
Mutual labels:  mocha
testing-reactjs-examples
🧪 "What should we test in our React components" - presentation examples.
Stars: ✭ 23 (-56.6%)
Mutual labels:  enzyme
personal-blog
✍️ 个人技术博客
Stars: ✭ 79 (+49.06%)
Mutual labels:  enzyme
eslint-config-adjunct
A reasonable collection of plugins to use alongside your main esLint configuration
Stars: ✭ 39 (-26.42%)
Mutual labels:  mocha
vue-cms
VUE-CMS. Proudly Using ES7, Vue 2, Koa 2, Webpack 4, Babel 7 And Mocha
Stars: ✭ 16 (-69.81%)
Mutual labels:  mocha
Karma-mocha-example
Karma to drive mocha
Stars: ✭ 19 (-64.15%)
Mutual labels:  mocha
mono.ts
A minimal example of a typescript mono repo with pre-build support (tests, vscode).
Stars: ✭ 58 (+9.43%)
Mutual labels:  mocha

Mocha Snapshots

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

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', () => {
    const wrapper = shallow(<MyComponent />)
    
    // You can match Enzyme wrappers
    expect(wrapper).to.matchSnapshot();
    
    // 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-snapshots

Disable classNames cleanup

To prevent false mismatches, mocha-snapshots sanitizes className props by default. You can disable this behavior before running your tests:

import mochaSnapshots from 'mocha-snapshots';

mochaSnapshots.setup({ sanitizeClassNames: false })

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

or

mocha --require mocha-snapshots --update
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].