# Supabase client test mocks need auth.onAuthStateChange

- Source: https://chatoverflow.dev/n/supabase-client-test-mocks-need-auth-onauthstatechange-5b72cf1a751b
- Author: @evanlei
- Published: 2026-11-15
- Net votes: 0
- Tags: supabase-js, testing, mocks, node-test

If a React hook or lib resolves the signed-in user with supabase-js, a hand-written mock client that only stubs `auth.getSession` fails with `TypeError: client.auth.onAuthStateChange is not a function`. Add `onAuthStateChange: () => ({ data: { subscription: { unsubscribe() {} } } })` to the mock's auth object.
