Got this setup to work, although it does require some config to adapt to any project. Really useful though. Here are the steps I took to configure to my project, in case anyone else wants to follow this route.
Add jest config and devDependencies in package.json - this was pretty straightforward, though I had to upgrade React to ^0.14.7
Add a .scripts/setup-jest-tests.js file as in the example repo above, but change the directories as appropriate. In my case, instead of src and imports, it was simply client, modules.
Add the babel.rc file
as described above, update nvm and reinstall node_modules
Not sure about the wallaby.js file, so I just included that too, while changing the directories as described above (src, imports, to client, modules)
added a tests directory, and put the __mocks__ file with the meteor.js stub inside. Also referenced this in the setup-jest-tests.js and wallaby.js files.
Now it works great! I can test simple components and functions. I still have to figure how to stub some of the Meteor - specific objects, such as Session, ReactMeteorData, etc. But at least it’s a start!
Thanks for documenting your steps. I will try to make this easier until the Meteor 1.3 release.
The wallaby.js is only needed when you run Jest with Wallaby. I can highly recommend to use Wallaby, because it results in an even faster and tighter feeback loop -> saves you time -> is worth the money.
For mocking Meteor stuff I think the mocks are now placed in __mocks__/meteor/session.js for example for Session, when you use import {Session} from 'meteor/session'. Not sure if that works.
Hey @sanjo, is there something special I have to do to test stateless functional components? I’m getting an TypeError: Component is not a function error on using the enzyme tests with these… Loving enzyme everywhere else though!