CoreMVP
After launch

Add a Test environment

View as Markdown

A Test environment is a second copy of your app with test billing. Vercel can follow a test branch; Cloudflare requires a manual Test Worker deploy.

Give your agent this prompt
Set up a separate Test environment for <framework> on <host> with test billing after approval.
Follow https://coremvp.com/en/docs/deployment/after-launch/test-environment.md and its prerequisites.
Ask me before creating or linking provider resources, writing secrets, replacing existing settings, pushing a deploy-triggering branch, deploying or changing Production. Finish when Supabase passes for the pushed commit, the matching Vercel deployment passes or the Worker deploy succeeds for that commit, and the changed behavior and relevant test checkout work on the Test URL.
Report what changed, the check results and anything you could not run.

You'll need

A second host project (Vercel) or Worker (Cloudflare), and a second Supabase project. Stripe test mode or Polar sandbox.

Build the Test copy

Test always uses test mode or sandbox. For Stripe, it keeps EMAIL_DELIVERY_MODE=test_capture with its own TEST_EMAIL_CAPTURE_TOKEN.

Repeat Deploy to Vercel with a new project name, such as <app>-test. A second Vercel project keeps its own settings. Then follow Add your database with the second Supabase project, and add email and test billing to the Test project.

Test builds from the same config as Production under another Worker name, with its own settings file, .env.cloudflare.test. Follow Deploy to Cloudflare with three changes:

  1. Skip Name the Worker. Your config keeps the Production name.

  2. In Save your app URL, create .env.cloudflare.test with these two lines instead:

    Replace <app> with your Worker name and <your-subdomain> with your Workers subdomain.

    (set -C; echo 'CLOUDFLARE_WORKER_NAME=<app>-test' > .env.cloudflare.test) &&
    echo 'NEXT_PUBLIC_APP_URL=https://<app>-test.<your-subdomain>.workers.dev' >> .env.cloudflare.test

    If the file already exists, inspect it and ask before replacing its settings.

  3. In every build and deploy command, use .env.cloudflare.test in place of .

Then follow Add your database with the second Supabase project, and add email and test billing. Add each setting to .env.cloudflare.test and never recreate the file: its first line sends every build to the Test Worker, so a deploy never replaces Production.

Create the test branch

git push origin main:test

Connect Test to the test branch

In the Test Supabase project, connect the GitHub integration as in Ship on merge, with Production branch name set to test.

Connect the Test project to your repository as in Ship on merge. Then, in the Test project, open Settings → Environments → Production and set Branch Tracking to test.

Keep deploying the Test Worker from your computer, with the build and deploy commands and .env.cloudflare.test from the step above. Workers Builds checks that the Worker name matches your config, which keeps the Production name.

Check a change on Test first

From your change's branch:

Replace <change-name> with the branch to test.

git switch test && git pull &&
git merge <change-name> &&
git push

On Cloudflare, build and deploy Test from this exact pushed test commit before switching branches. Then run git switch <change-name>. When Test passes the checks below, open the pull request to main as in Ship a change.

Check it works

The commit you pushed to test shows passing checks from Supabase and, on Vercel, from the matching Test deployment; on Cloudflare, the manual Worker deploy succeeds. Your Test URL shows the change and the relevant test checkout grants access. Production is unchanged until you merge to main.

Watch the billing checks

Run the Stripe billing checks against Test and watch them in a browser. Playwright, a browser automation tool, pays with Stripe's test card the way a customer would, so you can rerun the same checks after every change. Your local needs the Test project's NEXT_PUBLIC_SUPABASE_URL, SUPABASE_SECRET_KEY and TEST_EMAIL_CAPTURE_TOKEN, plus the Test app's NEXT_PUBLIC_STRIPE_ price IDs, as described in Hosted checks. The checks compare each purchase with those price IDs and read them from your shell, so load first. Before the subscription check, activate the Stripe customer portal in test mode.

set -a; source .env; set +a
export TEST_BASE_URL=https://<app>-test.<host-domain>
unset PROD_E2E_AUTH_MODE
./coremvp prod e2e billing:lifetime --headed

export PROD_E2E_AUTH_MODE=signup
./coremvp prod e2e billing:subscription --headed

A browser buys with Stripe's test card, sets up the account and opens the paid content. Each command ends with result production E2E passed and the Test URL. Pointed at a live app, both commands stop before any checkout.

One passing ./coremvp prod e2e billing:lifetime --headed run against a Next.js Test environment on Vercel, shown at 2.5× speed. The test account's email and name are hidden.

Was this page helpful?

On this page