#Convex Preview Deployments for testing
1 messages · Page 1 of 1 (latest)
Hi @zealous wind. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Yes, you can create a Convex preview deployment of your backend and use it for end-to-end (E2E) testing with Playwright, instead of setting up a local backend. Convex preview deployments are designed to provide a production-like environment for testing backend changes before pushing them to production. This is commonly used in conjunction with frontend hosting providers like Vercel or Netlify, but you can also generate preview deployments independently by using a Preview Deploy Key and the Convex CLI.
To do this:
- Generate a Preview Deploy Key from your Convex dashboard.
- Set the
CONVEX_DEPLOY_KEYenvironment variable to this key in your CI or local environment. - Run
npx convex deploy --preview-create my-branch-nameto create a preview deployment for your branch or test context. - Point your Playwright tests at the URL of the preview deployment.
This approach allows you to run E2E tests against a fresh, isolated backend that does not affect your production or development data. Note that preview deployments are automatically cleaned up after 14 days or when a new deployment with the same name is created, and they require a Convex Pro plan. Also, initial data can be set up by running a function during deployment, but importing data from other deployments is not currently supported for preview deployments Preview Deployments.
This method is especially useful for testing in a production-like environment and is recommended for manual or automated E2E testing workflows Testing patterns for peace of mind.
If you do not want to use preview deployments, you can alternatively run tests against a local backend, which is faster and does not consume hosting resources, but may not fully replicate your hosted environment.