All Projects → tylercollier → Redux Form Test

tylercollier / Redux Form Test

Shows how to do unit tests and integration tests with Redux-Form

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Redux Form Test

Enzyme
JavaScript Testing utilities for React
Stars: ✭ 19,781 (+8850.68%)
Mutual labels:  test, enzyme
react-file-input
⚛️  A file Input, with drag'n'drop and image editor for React
Stars: ✭ 71 (-67.87%)
Mutual labels:  enzyme, redux-form
react-phoenix-users-boilerplate
Elixir/Phoenix + React + users template/boilerplate.
Stars: ✭ 71 (-67.87%)
Mutual labels:  enzyme, redux-form
React Fake Props
🔮 Magically generate fake props for your React tests
Stars: ✭ 604 (+173.3%)
Mutual labels:  test, enzyme
React Generate Props
Generate default props based on your React component's PropTypes
Stars: ✭ 23 (-89.59%)
Mutual labels:  test, enzyme
Push Starter
React Redux Starter with SSR 🤖
Stars: ✭ 43 (-80.54%)
Mutual labels:  enzyme, redux-form
Should Enzyme
Useful functions for testing React Components with Enzyme.
Stars: ✭ 41 (-81.45%)
Mutual labels:  test, enzyme
Reactjs Crud Boilerplate
Live Demo
Stars: ✭ 83 (-62.44%)
Mutual labels:  enzyme, redux-form
Redux Form
A Higher Order Component using react-redux to keep form state in a Redux store
Stars: ✭ 12,597 (+5600%)
Mutual labels:  redux-form
Softest
Recording Browser Interactions And Generating Test Scripts.
Stars: ✭ 208 (-5.88%)
Mutual labels:  test
Gradle Testsets Plugin
A plugin for the Gradle build system that allows specifying test sets (like integration or acceptance tests).
Stars: ✭ 182 (-17.65%)
Mutual labels:  test
Hitchhiker
a Restful Api test tool
Stars: ✭ 2,175 (+884.16%)
Mutual labels:  test
Cornichon
Scala DSL for testing HTTP JSON API
Stars: ✭ 211 (-4.52%)
Mutual labels:  test
Grunt Saucelabs
Grunt task for running all your browser tests using Sauce Labs
Stars: ✭ 182 (-17.65%)
Mutual labels:  test
Nx Admin
👍 A magical 🐮 ⚔ vue admin,记得star
Stars: ✭ 2,497 (+1029.86%)
Mutual labels:  test
Buildbuddy
BuildBuddy is an open source Bazel build event viewer, result store, and remote cache.
Stars: ✭ 182 (-17.65%)
Mutual labels:  test
Zson
专为测试人员打造的JSON解析器
Stars: ✭ 181 (-18.1%)
Mutual labels:  test
Pkg Ok
👌 Checks paths and scripts defined in package.json before you publish
Stars: ✭ 219 (-0.9%)
Mutual labels:  test
Awesome Learning
Awesome Learning - Learn JavaScript and Front-End Fundamentals at your own pace
Stars: ✭ 216 (-2.26%)
Mutual labels:  enzyme
Androidunittest
Save time & clear your unit tests on Android !
Stars: ✭ 205 (-7.24%)
Mutual labels:  test

Redux-Form Test

This project shows how to do unit and integrations tests with Redux-Form.

For redux-form version 6

This project now uses redux-form version 6. To see test examples for redux-form 5, see this tag: redux-form-5.

Basic premise

Ideally you should do both unit tests and integration tests with your form components.

First, make sure you understand the general idea of testing connected components from the Redux "Writing Tests" doc. Search for the section called Connected Components.

So, you should have a "dumb" (aka presentational) React component that is separate from any connection to Redux and Redux-Form. It takes props. That's it. You test that with unit tests.

You should also have a container React component that connects the presentational component to Redux and Redux-Form. To test this, your test becomes an integration test because you're hooking up your presentational component to redux's store. You're integrating them.

To make this separation clear, I named the presentational component ContactFormComponent, and the container ContactFormContainer, in 2 different files, although you could also set it up so they are in one file.

What should I look at?

This project is very simple. First, run the site (described below) to see what the form looks like. Then view the tests. Take a look at the tests directory and follow the code into the app directory. I recommend you look at the tests/unit directory first, and then tests/integration, because the former is simpler and is a basis for the latter.

The test files are commented with specific pointers.

How to run the site

$ npm install
$ npm run dev

This will run webpack-dev-server, which defaults to port 8080, so you can visit http://localhost:8080. The site is trivial, and exists just to give you a visual of what's happening.

TODO: Fix hot reloading. I installed react-hot-loader 3.0.0-beta.3 because of a warning I received when using the react-hot loader in babel, which said to put react-hot-loader/babel in the plugins section of the .babelrc file, but I haven't done the rest of the wiring yet.

How to run the tests

$ npm install
$ npm run test

Technologies

These tests are written to run with the mocha test framework. I use the chai assertion library to make it more readable; chai-enzyme is also used. But what I'm trying to show off is testing Redux-Form, so of course you could use a different test framework.

Similarly, I'm using Enzyme, which is far better than the basic Facebook React Test Utils. Enzyme is more convenient and intuitive to write, easier to read, and more powerful with great debug helpers. I'm using sinon as a spy library, which is how we know if the functions we pass into our components get called properly. You could exchange sinon for another spy library.

License

MIT

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].