A green 200 in your webhook logs doesn't mean a signup passed. A Before User Created hook can return HTTP 200 with an error object in its body. Supabase Auth reads that object before deciding whether to insert the user.

That gives you two things to test: the hook's response and whether a user actually exists afterward.

Start with three cases, not two

Say your signup policy screens disposable email addresses. You want to allow an accepted address, reject a disposable address, and reject when you can't get a verdict. The last two are both rejections, but they should not tell the user the same thing.

Classifier result Hook sends Expected signup outcome
Accepted 204, no body Continue
Disposable 200 with error.http_code: 403 Ask for a different address
Unavailable 200 with error.http_code: 503 Ask the user to try again

Here's a local test for that response contract. It uses Node's built-in test runner and a stub classifier. It does not start Supabase, make network calls, or implement webhook signature verification.

// signup-hook.test.mjs import assert from 'node:assert/strict'; import test from 'node:test'; async function replyForEmail(email, classify) { let verdict; try { verdict = await classify(email); } catch { verdict = 'unavailable'; } if (verdict === 'accepted') return new Response(null, { status: 204 }); const disposable = verdict === 'disposable'; return Response.json({ error: { http_code: disposable ? 403 : 503, message: disposable ? 'Use a permanent email address.' : 'Try again later.', }, }, { status: 200 }); } test('accepted address continues', async () => { const res = await replyForEmail('accepted@example.test', async () => 'accepted'); assert.equal(res.status, 204); assert.equal(await res.text(), ''); }); test('a successful HTTP delivery can still reject signup', async () => { const res = await replyForEmail('disposable@example.test', async () => 'disposable'); assert.equal(res.status, 200); assert.equal((await res.json()).error.http_code, 403); }); test('classifier failure is not marked as a disposable address', async () => { const res = await replyForEmail('outage@example.test', async () => { throw new Error('simulated dependency failure'); }); assert.equal(res.status, 200); assert.equal((await res.json()).error.http_code, 503); }); 

Run it with node --test signup-hook.test.mjs. The addresses are synthetic labels, not test fixtures for a real detector.

Then check what Supabase actually stored

In a development project with a configured hook, use your normal signup screen and two fresh addresses you control: one permanent, one known disposable. After each attempt, check Authentication → Users in the same project. You want the permanent address to appear and the disposable one not to appear. A missing session doesn't prove rejection when email confirmation is enabled. An unrelated error, such as a signup rate limit, doesn't prove the policy worked either.

A real HTTP endpoint must verify Supabase's signed request before trusting the payload. If your hook calls a dependency, bound its timeout below Supabase's five-second HTTP hook deadline so you have time to return a deliberate error. Failing closed means an outage can stop legitimate signups, too. In the app, distinguish “try again” from “use a different email.”

AI drafted this article from the public Supabase documentation. The example tests the local response contract, not a live Supabase project.