Jest adds multiple layers on-top:
- A mock library (also called stubs) in order to create fake functions and assert that they are called as you want: http://facebook.github.io/jest/docs/mock-functions.html#cont...
- A way to provide an alternate implementation for dependencies using require(): http://facebook.github.io/jest/docs/common-js-testing.html#c...
- It inspects the shape of your dependencies and return a mocked version of them: http://facebook.github.io/jest/docs/automatic-mocking.html#c...
- Finally, it works in node instead of the browser and uses jsdom to let you test code related to the DOM. (It also runs tests in parallel)
jest is a test runner that includes a few additional things to try to make all aspects of writing and running tests a little easier...such as:
* Searches for tests to find + execute so that you can put tests near the modules they are testing
* Runs tests in parallel processes so that your test runs finish sooner
* Replace's node's built-in require() function with a custom one that acts almost entirely the same -- except (by default) it returns mocked versions of modules (rather than the real things) when your tests run
* Gives you a fake DOM implementation (using jsdom) so that you can test code that depends on DOM APIs on the command line without having to boot up a browser
The code is now a little stale and dated, but it basically just shells out to the bin/jest.js script included with Jest. Turned out no more than a ~30lines:
https://github.com/jeffmo/react/commit/7a72cbba0eb57844f4e22...