How to set up Continuous Integration (CI) testing
The Liveblocks dev server lets you run your end-to-end tests in CI without needing Liveblocks credentials, and without usage limits. Your tests behave identically whether you run them locally or in CI.
What we’re setting up
You’ll run the Liveblocks dev server as a
service container
in your GitHub Actions workflow. Your app connects to http://localhost:1153
instead of Liveblocks production, using the built-in "sk_localdev" secret key.
No production credentials required.
Step 1: Add a test environment file
Most frameworks automatically load a .env.test file when running tests. Create
one with the dev server values:
Since these are well-known dev-only values, it’s safe to commit this file to your repository.
For the base URL to be accessible in client-side code, some frameworks require
a specific prefix. For example, Next.js requires NEXT_PUBLIC_ and Vite
requires VITE_. Adjust the variable name accordingly. In all examples below,
we assume Next.js.
Step 2: Reference the environment variables
In your client, read the base URL from the environment variable:
In your Node backend, read both the base URL and secret:
When these variables are not set, your app connects to Liveblocks production as usual.
Step 3: Add the GitHub Actions workflow
Use the services block to run the Liveblocks dev server as a service
container. GitHub Actions starts it automatically before your steps run, and
your tests can connect to it on localhost:1153.
That’s it! The service container provides the dev server, and the .env.test
file supplies the configuration. No additional setup needed.