
Supabase Auth keeps its session in the browser: by default the JavaScript client stores the access and refresh tokens in local storage under a key tied to your project reference, and refreshes them in the background. That's convenient for users and awkward for tests. Run thirty sign-up and sign-in checks in one browser context and they share storage, so test 14 quietly inherits the session from test 13, and the bug you were looking for (an expired refresh token, a half-finished email confirmation) never shows.
I solved that with separate browser profiles. Each test user gets one BitBrowser profile with its own storage, cookies and cache, and Playwright connects to each profile through BitBrowser's Local API. An AI assistant connected over MCP handles the boring part (listing, creating and arranging the profiles) while Playwright runs the auth flows against my own Supabase staging project. The assistant never clicks inside the app and never touches the Supabase dashboard.
The year-end release freeze is when this earns its keep. Every auth change that ships in December has to survive the January login spike, and this suite is how I know it will.
Contents
- Rules that come first
- What the suite covers
- The profile map
- Connect BitBrowser MCP (read-only first)
- Routine 1: build and arrange the 30 profiles
- Connecting Playwright through the Local API
- The test flows
- Keeping the suite honest
- Routine 2: the freeze-day run
- Device layer: none needed
- What the first runs usually find
- Offboarding and incidents
- Quick answers
- One next step
Rules that come first
Your project, your test users. The suite runs against a Supabase project you own: a local stack from the Supabase CLI or a staging project. Test users have addresses on a domain you control or in the local inbox the CLI provides. No real user's account is touched, and the suite never runs against production auth.
Auth rate limits are real. Hosted Supabase projects apply rate limits to auth endpoints and email sends, and the built-in email service is meant for trying things out, not for test suites. For staging, configure your own SMTP provider and check the limits in your project's Auth settings before you point thirty profiles at it. The local CLI stack is the safer default.
The assistant only organises. Over MCP it lists, creates, opens, arranges and closes profiles. It never clicks inside your app, never fills a form, never opens the Supabase dashboard, never changes settings, keys or billing. The auth flows run from Playwright code that you wrote and can read.
Locations stay honest. These profiles don't need proxies. Your test server sees your office connection, which is the truth.
What the suite covers
Auth bugs cluster around transitions, so the suite is built around them:
- Sign-up with email confirmation, including the case where the user clicks the link in a different profile (a different device, in real life).
- Sign-in with password, correct and wrong, and the lockout or error message after repeated failures.
- Magic link sign-in, including an expired link.
- Password reset, start to finish, and the old session being signed out.
- Session refresh, by shortening the JWT expiry on the test project and leaving a profile idle until the access token expires.
- Sign-out everywhere, where one profile signs out and a second profile with the same user should lose its session after refresh.
- OAuth sign-in with a provider's test app, if you use one.
- Row Level Security checks after sign-in: user A must not read user B's rows.
Thirty profiles is what those cases add up to when each needs two or three users in different states.
The profile map
Profiles are named after the user and state they hold. A BitBrowser group called supa-auth keeps them together; tags mark the flow.
| Profile | Test user | Starting state | Flow |
|---|---|---|---|
| SA-01 | t01@test.example | none | sign-up, confirm in same profile |
| SA-02 | t02@test.example | none | sign-up, confirm in SA-03 |
| SA-03 | t02@test.example | none | opens the confirmation link only |
| SA-04 | t04@test.example | confirmed | password sign-in |
| SA-05 | t04@test.example | confirmed | wrong password x5 |
| SA-06 | t06@test.example | confirmed | magic link |
| SA-07 | t06@test.example | confirmed | expired magic link |
| SA-08 | t08@test.example | signed in | password reset |
| SA-09 | t08@test.example | signed in | old session after reset |
| SA-10 | t10@test.example | signed in | idle until token expiry |
| SA-11 to SA-20 | t11 to t20 | signed in | RLS reads across users |
| SA-21 to SA-26 | t21 to t26 | signed in | sign-out everywhere pairs |
| SA-27 to SA-30 | t27 to t30 | none | OAuth with the provider's test app |
The test users come from a seed script against your test project. Keep the script and the table in the same folder of your repo.
Connect BitBrowser MCP (read-only first)
From BitBrowser 7.1.5 the client has an MCP server built in. In Settings > Browser Settings > Local API, turn on authentication control and copy the API token. MCP lives at http://127.0.0.1:54345/mcp; the token goes in the x-api-key header.
{
"mcpServers": {
"bitbrowser": {
"url": "http://127.0.0.1:54345/mcp",
"headers": {
"x-api-key": "<YOUR_API_TOKEN>"
}
}
}
}
The first prompt only reads:
List the profiles in the group "supa-auth" with name, tags and proxy
setting, and tell me whether the group exists. Do not create, open,
edit or delete anything. You only organise profiles and windows. Never
click inside a website, never fill forms, never log in, post, buy or
change any setting, key or payment.
Routine 1: build and arrange the 30 profiles
On a new machine the group doesn't exist yet. The assistant can create the empty profiles; the tests fill them.
Create a group called "supa-auth" and 30 browser profiles in it named
SA-01 to SA-30, with no proxy and default fingerprint settings. Tag
SA-01 to SA-10 "flows", SA-11 to SA-20 "rls", SA-21 to SA-26 "signout"
and SA-27 to SA-30 "oauth". Create them one at a time and report the IDs.
Do not open any profile. You only organise profiles: no clicks inside
websites, no logins, no posting, buying or changes to settings or payments.
Then, before a run:
Open the profiles tagged "flows" one at a time, in name order. Never open
two at once; wait for each window to be fully open. If you close a profile,
wait 5 seconds before opening the next. Arrange them in a 5 x 2 grid and
report the IDs that opened. You only organise windows: do not click inside
pages, do not log in, do not change settings or payments.
Most of the time, though, Playwright opens the profiles itself through the Local API, and the assistant is only there for setup and cleanup.
Connecting Playwright through the Local API
BitBrowser's Local API listens on 127.0.0.1:54345 with the same x-api-key header. Opening a profile through it returns a DevTools WebSocket address that Playwright can attach to. The sketch below opens one profile, runs a flow, closes it, and waits five seconds before the next; check the exact endpoint names and response fields against BitBrowser's API document for your client version.
import { chromium } from "playwright";
const API = "http://127.0.0.1:54345";
const KEY = process.env.BB_API_KEY!;
const sleep = (ms: number) => new Promise(r => setTimeout(r, ms));
async function bb(path: string, body: object) {
const r = await fetch(API + path, {
method: "POST",
headers: { "Content-Type": "application/json", "x-api-key": KEY },
body: JSON.stringify(body),
});
return r.json();
}
export async function withProfile(id: string, run: (page: any) => Promise<void>) {
const opened = await bb("/browser/open", { id });
const browser = await chromium.connectOverCDP(opened.data.ws);
const page = browser.contexts()[0].pages()[0] ?? await browser.contexts()[0].newPage();
try { await run(page); }
finally {
await browser.close();
await bb("/browser/close", { id });
await sleep(5000); // never open the next profile before this one has let go
}
}
The runner calls withProfile for each profile in sequence. Sequence matters: two profiles of the same user running at once would test a race you didn't mean to test.
The test flows
Each flow is an ordinary Playwright test that receives a page from withProfile. A few notes from building them:
Email confirmation across profiles. SA-02 signs up; the test reads the confirmation link from the local inbox (the CLI stack runs an email testing server; recent versions use Mailpit on port 54324 by default) and hands the URL to SA-03, which opens it. Then SA-02 refreshes and should see a confirmed session or a clear prompt to sign in, depending on your settings.
Token expiry without waiting an hour. On the test project, set a short JWT expiry in Auth settings. SA-10 signs in, idles past the expiry, then calls an RLS-protected table. The client should refresh silently. If it throws, you found the bug before your users did.
RLS pairs. SA-11 to SA-20 sign in as ten users, each inserting one row. Then each tries to read the other nine. Every read must return zero rows. This is the test I'd keep if I could keep only one.
Sign-out everywhere. SA-21 and SA-22 are the same user in two profiles. SA-21 calls a global sign-out; SA-22 refreshes and must land on the sign-in page.
OAuth. Use the provider's test or development app, test accounts you own, and your staging callback URL. If the provider shows a consent screen, the test clicks through it as the test user; that's your own app's flow.
Keeping the suite honest
A test suite that always passes is either very good or not testing anything. Two habits keep this one useful. First, every flow has a deliberate failure twin: the wrong-password test expects an error, the expired-link test expects a refusal, and the RLS pairs expect empty results. If a twin ever passes when it should fail, the suite itself is broken, and I stop and fix it before trusting anything else.
Second, I keep a short changelog of auth settings on the test project: JWT expiry, email confirmation on or off, allowed redirect URLs, the SMTP provider. When a test that passed last week fails today, the changelog usually explains it faster than the stack trace. Supabase's dashboard doesn't keep that history for you in a form I find easy to read, so a text file in the repo does the job.
There's also the question of what not to test here. Load testing auth belongs in a separate tool with its own limits and an agreement with whoever runs the infrastructure. These thirty profiles exist to prove behaviour, one user at a time, not to hammer the server.
Routine 2: the freeze-day run
On the day of the release freeze I run the whole suite twice: once against the local stack, once against staging with custom SMTP.
Close any open profiles in "supa-auth" one at a time, waiting 5 seconds
after each close, then report that none are open. Do not delete anything.
You only organise profiles: no clicks inside pages, no logins, no changes
to settings, keys or payments.
Then npx playwright test --workers=1. One worker, because profiles of the same user must not overlap. On my laptop the full run takes about twelve minutes.
After the run, the assistant closes anything left open with the same prompt, and I clear the test users with the seed script's reset command.
Device layer: none needed
No cloud phone and no cloud PC in this row. If you want the suite to run nightly without your laptop, the same scripts work on a Windows cloud desktop: BitCloudPC gives you Windows 10 or 11 machines you use from a browser, with one-click reinstall when you want a clean slate. If you also ship a mobile app on Supabase, BitCloudPhone Android devices let you repeat the sign-in and deep-link checks on real Android builds.
BitBrowser bundles four ideas: many accounts managed from one place, one-click sync across windows, several kinds of device, and isolation between profiles. A test suite only needs the last one to be solid, and isolation is what fixes the shared-session problem from the first paragraph.
What the first runs usually find
I won't promise what your suite will catch, but these are the classes of bug the profile setup is built to expose, and they're the ones I'd look for first in any project:
The confirmation link opened in a second profile fails to complete sign-in because the app expected the original tab's state. That's a real-world bug: people sign up on a laptop and click the email on their phone.
The idle profile throws on its first request after the access token expires, because one code path calls the database before the client finished refreshing. Users see it as "I opened the app this morning and had to log in again".
A policy written for select was copied for update and forgot the user check. The RLS pairs catch it on the first run.
Global sign-out works for the web app but a background job keeps a service-role connection open and keeps writing as the user. Not strictly an auth bug, but the sign-out pair is where it shows.
Offboarding and incidents
A developer leaves: remove their BitBrowser seat, rotate the Local API token (it sits in their MCP config and their .env), and rotate the staging service role key if they had it.
A test leaks into production: stop the runner, check the SUPABASE_URL your test environment loaded, and add a guard that aborts when the URL matches production. Mine refuses to start unless the project ref is on an allow list.
Auth emails stop arriving on staging: check the SMTP provider's log and the Auth rate limits first. Thirty sign-ups in two minutes can trip either.
A profile won't open through the API: close it, wait 5 seconds, retry once. If it still fails, let the assistant list the group to confirm the ID, and run that test alone.
Flaky RLS test: flakiness in an RLS read almost always means two tests shared a user. Check the profile map.
Quick answers
Why not Playwright's own browser contexts? They isolate storage well inside one run. Profiles persist between runs, which I want for the "idle until expiry" and "returning user" cases, and they're visible as windows when I need to watch a flow.
Can the assistant run the tests? No. It creates, opens, arranges and closes profiles. Tests run from your code and your terminal.
Does this need proxies? No. Your test server should see your real connection.
How many profiles do I need on the free plan? BitBrowser's free plan includes 10 profiles, enough for the "flows" set. The RLS and sign-out pairs need more.
Will this work with Supabase's newer auth options? The pattern does. Each new option is one more flow and one or two more profiles.
What about mobile deep links for magic links? Test them on a phone; desktop profiles only cover the web flow.
On plans: if you're setting this up for a team, BitBrowser's Year-End Mega Sale runs November 11 to December 12, 2026, and the 24-month plan is 50% off (3 months 20%, 6 months 30%, 12 months 40%). For a team that plans its test infrastructure through 2028, 24 months means one budget line instead of eight renewals. Cloud Phone and Cloud PC plans are up to 40% off in the same window. Check it through the BitBrowser link near the top.
One next step
Seed ten test users on your local Supabase stack, create the "flows" profiles with the assistant, and wire one test (password sign-in) through withProfile. When that passes twice in a row, add the RLS pairs; they're the test that protects your data.



Top comments (0)