Jacob Ruiz

View Original

GraphQL: Writing Tests for Canceling a Stripe Subscription

We’ve already written tests for creating a subscription in Stripe, now it’s time to write some basic tests for the other case: canceling the subscription in Stripe.

First, we can create a function that takes in a cookie string (for authentication), and makes a call to our GraphQL API using Axios.

See this content in the original post

Now we can use this function to test a couple of cases:

1. It throws an error if the user is not logged in

See this content in the original post

2. It returns a user if user is logged in and downgrade was successful

See this content in the original post