next.js testing with jest

I stumbled upon the testing overview in the react docs, which says The default template of React Native ships with [Jest]( testing framework. Interesting. I’ll have a quick go of Jest just to see what’s what.


[about 30 minutes later…] Well… I wish I’d stumbled across this first, this was super easy!

yarn add --dev jest

in package.json:

  "scripts": {
    "test": "jest"

Create a ./tests/foo.spec.js file with the contents:

test('true is true', () => {

And run

yarn test

The nice thing about Jest, is that it:

  • has fluent syntax so I don’t feel the need for chai,
  • appears to have mocking functionality, but we’ll see later if that’s any good for TDD. This might mean we don’t need sinon.
  • it clearly is a replacement for mocha, so we can swap that out

Enzyme on the other hand might still add value if it makes testing components easier! We’ll see how that fits in later.

Popular posts from this blog

Taking a memory dump of a w3wp process


GitLab Badges