Skip to content

WINTR/Testing-React-with-Mocha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Testing React and Flux (McFly) with Mocha

Get going

  1. npm install
  2. mocha

Tools

  • Mocha for running tests
  • Chai for assertions
  • Sinon for stubs, spys, etc
  • Nock to mock external API calls
  • Rewire to mock require calls and to allow private method testing
  • Decache to help out with the Flux dispatcher being a singleton

Patterns

React Components

  • Use the React Test Utils
  • Use Rewire's __set__ method to mock nested React components. See - ParentTests.coffee for example.

Flux Stores

  • Use dispatcher.dispatch to dispatch fake actions
  • Use Rewire's __get__ method to expose private methods
  • See ItemStoreTests.coffee for examples

Flux Actions

  • Use Sinon Spys and spy on dispatcher.dispatch to make sure your actions are firing as expected

External API calls

  • Use Nock to mock any external APIs that are needed in your tests

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors