Guides / Time Machine
How to test renewals with Chargebee's Time Machine
Last updated
You can't wait a month to see if a renewal invoice is right. Chargebee's Time Machine lets a test site jump forward in time so you can check it today.
What the Time Machine does
On a Chargebee test site, the Time Machine moves the site's clock forward. Anything that would have happened in between runs: subscriptions renew, trials end and invoices are created. It only exists on test sites.
Typical things to test with it:
- Does the first renewal invoice have the right amount?
- Is usage billed correctly at the end of the period?
- What happens when a trial ends?
- Do scheduled changes (like a downgrade at term end) apply on the right date?
The manual way
With the API
Each test site has a single time machine called delorean.
GET /api/v2/time_machines/deloreanshows the site's current time and status.POST /api/v2/time_machines/delorean/travel_forwardwith adestination_time(Unix timestamp) moves the clock forward.
Travel runs in the background. Check the status until it's finished before you look at invoices, or you'll see half-finished results.
A typical manual test
- Create a customer and a subscription.
- Record usage, if the plan is metered.
- Travel forward one month and wait until it's done.
- Open the new invoice and check the total by hand.
This works, but you have to repeat every step each time you change a price. That's where mistakes slip in.
Note: time travel moves the whole site, not one customer. Every subscription on the site moves forward with it. That's another reason to keep a separate, clean test site.
The faster way with Testabee
In Testabee you write a test once as a short script and run it as often as you like:
subscribe pro-EUR-Monthly, seats-EUR-Monthly x5
usage api-calls-EUR 1000
travel 1 month
expect invoice 129.00
Each run creates a fresh customer, runs the steps in order, waits for time travel to finish and checks the invoice total. If the total is wrong, the run stops and shows you which line failed. Scenarios only run on test sites.
You can also move the site's clock forward directly from Testabee's tools, without writing a script.