#jonah-checkout-testclock

1 messages · Page 1 of 1 (latest)

hushed marlinBOT
jagged venture
#

jonah-checkout-testclock

#

Hey @nocturne bear, Checkout doesn't directly support test clocks.

nocturne bear
#

directly?

#

How can I make it work with my test?

jagged venture
#

you can't, that's what I meant

nocturne bear
#

I've got a UI integration test that I want to fast forward.... okay haha any hack or anything you can think of?

jagged venture
#

No that's mostly impossible. You can use TestClock outside of Checkout

#

But really you shouldn't be writing tests like this that interact with Checkout

nocturne bear
#

Okay, so maybe I've done something stupid with the architecture.

#

I have 2 type of tests: CLI and UI.

#

My CLI creates subscriptions using Subscription.create, whereas my UI uses a checkout.

jagged venture
#

yeah I understand, but really you should mock all of Stripe entirely in your test

#

not hit our API over and over for your tests

#

Also we could change the Checkout UI at any time and break your tests

nocturne bear
#

So what would you suggest for the mock?

#

Sorry, a little new to this.

jagged venture
#

You would mock Stripe entirely, never hit Stripe, never open Checkout, etc. You simulate Checkout happening for example by having a stub/mock of what a Checkout Session/Customer/Subscription looks like before/after payment

nocturne bear
#

Not sure how that would test the webhooks

#

Still need to make sure those are tested, no?

jagged venture
#

Your webhook is an endpoint you can hit in your test with fixtures/mocked data

nocturne bear
#

Okay fair, thanks.

What about including a coupon id in a checkout session? I didn't see this in the docs