3. “For a unit test to operate on a truly isolated unit
of the application, we need to mock every
module except the on we are testing.”
– facebook.github.io/react/blog/2014/09/24/testing-flux-applications.html
6. “Dummy objects are passed around but never
actually used. Usually they are just used to fill
parameter lists.”
–Martin Fowler [Mocks Aren’t Stubs]
7. “Fake Objects actually have working
implementations but usually take some shortcut
which makes them not suitable for production
(i.e.: In memory database)”
–Martin Fowler [Mocks Aren’t Stubs]
8. “Stubs provide canned answers to calls made
during the test, usually not responding at all to
anything outside what’s programmed in for the
test.”
–Martin Fowler [Mocks Aren’t Stubs]
9. “Mocks objects pre-programmed with
expectations which form a specification of the
calls they are expected to receive.”
–Martin Fowler [Mocks Aren’t Stubs]
14. Jest
• Developed and used internally at Facebook
• Runs tests in parallel
• Mock by default
• Jasmine style syntax (describe, it, beforeEach)
• Automatically finds tests to execute
• Can test asynchronous thing synchronously
• Fake DOM available via jsdom
• Support for preprocessors (jsx, es6, coffee)
15. Installing & Using Jest
• $ npm install --save-dev jest-cli
• “scripts”:{ “test”: “./node_modules/.bin/jest” }
• put tests in any `__tests__` directory
• $ npm test