#r3v3rb

1 messages · Page 1 of 1 (latest)

charred dirgeBOT
tacit kettle
#

Hi there

#

If you are doing unit testing or any large amount of testing then you want to mock responses as opposed to actually hitting the API

#

That discusses how to handle automated testing

swift stone
#

nope, just a single test rather than having to complete a checkout in a browser each time

tacit kettle
#

Okay then using the CLI is going to be the easiest way to handle this but you can't use the same Checkout Session ID each time

#

You can use stripe trigger via the CLI to easily trigger a new checkout.session.completed event though

swift stone
#

bugger

#

😦

tacit kettle
#

Why do you want the same ID each time?

swift stone
#

the session id is stored against my user

tacit kettle
#

If you are just doing a one-off test then that shouldn't matter and you should run through your entire flow and ensure you are handling the new ID and storing it correctly?

#

Otherwise, mocking is still the way to go here

#

So just simulate the response using the ID that you want

swift stone
#

okay, i'll just have to keep entering details in checkout then

tacit kettle
#

Why? That will create a new ID each time too?

swift stone
#

how can I simulate the response with an id?

tacit kettle
#

You just go through the flow once, look at the response, then create your own mock object for that response to use each time you run the test