14 Followers
·
Follow

Easily achieve large coverage of your API through integration tests using Jest snapshots in Node.js

Image for post
Image for post
Photo by Ferenc Almasi on Unsplash.

Snapshot testing was popularized by frameworks like Jest in order to quickly and effectively track unintended changes to React components. However, the concept can be taken away from the front end and find equal utility for back-end testing.

In this article, I’ll show you how to easily achieve large coverage of your API through integration tests using Jest snapshots in Node.js.

In the next few sections, we’ll cover:

  • The benefits of snapshot testing
  • How to set up a testing environment
  • Managing snapshots tests over time

So let's get started.

Benefits of Snapshot testing

Testing often has a sweet spot. The goal is rarely 100% coverage, but you should aim to use the right kind of testing and find a balance between fluidity and stability. …

An end-to-end guide for building commission-based software with Stripe

Image for post
Image for post
Photo by Morgan Housel on Unsplash

I recently built a platform on Stripe, which has fantastic documentation but a lot of it. I found it difficult to connect each service for a complete end-to-end flow. In this article, I’ve consolidated hours of research and reading into a step-by-step guide with links to the official docs.

Stripe provides a fantastic suite of tools to process one-time and recurring payments. It’s made the development of platforms and marketplaces a far more realistic goal for small teams.

With the Stripe API you no longer have to concern yourself with compliance or security edge cases.

Here I’ll be using Stripe Connect to show you how a platform can process payments on behalf of a supplier. You’ll also be able to take a commission on each transaction. …

Image for post
Image for post

I always liked the idea of GitHub actions because it means less third-party dependencies on your CI/CD flow. The UI, however, is somewhat lacking compared to other providers such as Circle CI, but this is something improving over time.

Here I’ll be using Cypress to test the full end-to-end flow of a web app connected to a mocked GraphQL API. The fact the API is GraphQL makes local stubbing with Cypress difficult, due to all requests going to the same endpoint. I feel mocking the API is, therefore, the best way to go.

I’ll be focusing purely on GitHub actions rather than the configuration of the application itself. …

About

Warren Day

Software Engineer | Creator of https://tomorrowapp.io | Follow me on Twitter https://twitter.com/warrenjday

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store