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:

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. …


Adding online booking to your Wix site is simple. Here we are using Tomorrow Scheduling which can easily be dropped onto your site so you’ll be up and running in minutes.

Setup Tomorrow

First head over to Tomorrow and login or create a new account for free. https://www.tomorrowapp.io

Once you’re logged in you’ll be on the admin panel, then head over to Account > Integration

Image for post
Image for post

Tomorrow Admin — Integration

Here you can find a URL which can be copied and pasted into your Wix website.

To copy the link click “Copy URL”.

Integrating with Wix

There are currently two options when integrating with Wix. Either by linking directly to your checkout, or adding the checkout into your site via an iFrame. …


Adding online booking to your Squarespace site is simple. Here we are using Tomorrow Scheduling which can easily be dropped onto your site so you'll be up and running in minutes.

Setup Tomorrow

First head over to Tomorrow and login or create a new account for free. https://www.tomorrowapp.io

Once you're logged in you'll be on the admin panel, then head over to Account > Integration

Image for post
Image for post
Tomorrow Admin — Integration

Here you can find a script which can be copied and pasted into your Squarespace website.

To copy the script click “Copy to Clipboard”.

Integrating with Squarespace

You can add custom scripts to Squarespace in a number of ways. Either using a code-block which is available on all plans or via site-wide code injection which requires a premium subscription. You can see more details here…


So you have a passion and want to share it. Promoting and selling classes online may seem daunting, but it doesn’t have to be difficult, it’s all about choosing the right tools. Here we’ll cover a simple guide on how to set up your online business in less than 5 minutes.

Ok, it’s the 20s again, maybe not quite as roaring as last time, a faint squeal at best, but the point is the future is now! So I’m not going to feed you the old dribble of setting up a WordPress site and just magically attracting customers. Let stick to modern tooling that makes the online part of your business a breeze, meaning you’re free to focus your energy on what you love. …


Feeling like your waisting away without that sweet squat rack? Pushups not quite cutting it? It might be difficult to keep things fresh and motivation high when the workout lacks the things you love. Let’s talk about how you can replace the “big five” exercises without any equipment.

The big five are:

Squats

Squats are most effective with heavy weight. Sure you can increase your reps without weight but in no way is it comparable to the classic. Instead try Pistol Squats to increase the load on each leg. …


In part one we discuss the use of RRule to describe the recurrences of a repeating event. Now let's cover the basic schema design for this system.

First, we need to store the actual event data so let’s create a model called Event

model Event {
id Int
title String
description String
host String
price Int
}

Here we can store basic information about an event. We now need to consider where to store information about the recurrence and we also need to think about handling exceptions and cancellations.

Let's create two models for repeating the event and adding exceptions.

model EventParent {
id Int
rule String
event Event
exceptions EventException[]…

Image for post
Image for post

Being physically active is an essential demand for our body to stay healthy. Exercising regularly comes with a lot of advantages, both physical and mental.

These can vary from blood pressure control to reducing the risk of conditions like heart failure and obesity. There are also several psychological benefits linked to regular exercise. May it be a short walk daily or going to the gym, being physically active bring a lot to improve our mental health.

Right now, we are all confined to our homes. This is, of course, helpful for our health amid the coronavirus pandemic as it reduces the spread. …


Image for post
Image for post

Both Codegen and Prisma automatically generate types. But a little extra config is required to make them play together nicely.

Generating types with Prisma

Prisma client has full TypeScript support out of the box. The client will be generated within your node_modules folder. Follow the official guide for specific details: https://www.prisma.io/docs/understand-prisma/introduction

But basically you generate a client by running

prisma generate

Generating types with Codegen

GraphQL Codegen can be used for many different scenarios. But in the context of a GraphQL API, you will want typings for your resolvers. These are generated automatically based on your GraphQL schema.

Take the following config (codegen.yml)

schema: src/**/*.graphql
generates:
./src/types/resolvers-types.ts: …

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