• Home
  • Books
  • Jest
  • Alpine.js
  • JavaScript
  • Node
  • More...
  • Search
  • About
  • Gear & Setup

Jest

A collection of 16 posts

#testing #jest #node #javascript #jest

Jest assert over single or specific argument/parameters with .toHaveBeenCalledWith and expect.anything()

With Jest it’s possible to assert of single or specific arguments/parameters of a mock function call with .toHaveBeenCalled/.toBeCalled and expect.anything(). The full example repository is at github.com/HugoDF/jest-specific-argument-assert, more specifically lines 17-66 ...

  • Hugo Di Francesco
    Author
4 min read
#Express #node #jest #Testing #javascript

A testing guide for Express with request and response mocking/stubbing using Jest or sinon

To test an Express handler, it’s useful to know how to successfully mock/stub the request and response objects. The following examples will be written both using Jest and sinon (running in AVA). The rationale for this is the following. Jest is a very popular “all-in-one” testing ...

  • Hugo Di Francesco
    Author
17 min read
#node #jest #testing #javascript #Sequelize

Mocking/stubbing ES6 classes in tests with examples of Sequelize model unit tests

This post goes through some patterns that can be used to unit test ES6 classes. The examples will use Jest module auto-mocking but should be portable to other module mocking libraries (eg. Proxyquire) with some modifications. In “Using ES6 classes for Sequelize 4 models&rdq ...

  • Hugo Di Francesco
    Author
2 min read
#jest #Testing #javascript

When to use Jest snapshot tests: comprehensive use-cases and examples 📸

There’s some nice use-cases for snapshot tests outside of the well-travelled React/Vue UI component ones. In other words, although React and Vue testing with snapshots is pretty well documented, that’s not the only place they’re useful. As a rule of thumb, you c ...

  • Hugo Di Francesco
    Author
6 min read
#jest #javascript #node #Express

Testing an Express app with SuperTest, moxios and Jest

Testing is a crucial part of the software development process. It helps to catch bugs, avoid regressions and to document the behaviour of a piece of software. Express is one of the most widespread libraries for building backend applications in JavaScript. What follows is a summar ...

  • Hugo Di Francesco
    Author
6 min read
#vuejs #jest #testing #javascript

From AngularJS to Vue.js, CommonJS and Jest

The trials and tribulations of kicking off an AngularJS -> Vue.js migration AngularJS was pretty groundbreaking. It’s still impressive to this day, packed with a router, an HTTP client, a dependency injection system and a bunch of other things I haven’t necessarily had the p ...

  • Hugo Di Francesco
    Author
7 min read
← Next Posts Page 2 of 2 

Get The Jest Handbook (100 pages)

Take your JavaScript testing to the next level by learning the ins and outs of Jest, the top JavaScript testing library.

Find out more close
Code with Hugo
Latest Posts Twitter Github Medium