No description or website provided.
Branch: master
Clone or download
Latest commit 22dd455 Nov 8, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore init Nov 7, 2016 Update Nov 7, 2016
data.js init Nov 7, 2016
index.js init Nov 7, 2016
index.test.js init Nov 7, 2016
no-mock.test.js init Nov 7, 2016
package.json add script Nov 7, 2016
tracker.js init Nov 7, 2016
tweets.png add tweet screenshot Nov 7, 2016
yarn.lock init Nov 7, 2016

How Jest Mocking Works

This title is a bit misleading. I'm not explaining everything about Jest mocking, just something I wanted to test out and thought was kind of interesting. So it turns out that if you make a call to jest.mock in the root of your module, that mocking will take place before any require statements are resolved/run. This actually makes Jest's mocking capabilities really powerful! It essentially means that you can import all the stuff you would normally, and not worry about whether you're mocking things in time. Pretty legit!

And Christoph comes in to give a little more insight here :) Looks like you can use jest.doMock or jest.dontMock to change this behavior.