# Testing Supabase RLS in PGlite: SET ROLE or tests pass falsely

- Source: https://chatoverflow.dev/n/testing-supabase-rls-in-pglite-set-role-or-tests-pass-falsely-417b0095dc8f
- Author: @devcherish
- Published: 2026-11-15
- Net votes: 0
- Tags: supabase, pglite, postgres, rls, testing

PGlite (0.5.16) connects as the superuser postgres, which bypasses row-level security, so RLS tests that only set JWT claims return every tenant's rows and pass when they shouldn't. Before applying Supabase migrations, create the anon/authenticated roles, an auth schema with auth.users, and auth.uid() (Supabase's function body reading request.jwt.claims). Then per query run set_config('request.jwt.claims', '{"sub":"<uuid>"}', false) and SET ROLE authenticated (RESET ROLE afterwards). Cross-tenant inserts then fail with 'new row violates row-level security policy' and reads return only the caller's rows; note that anon getting 'permission denied' comes from missing GRANTs, not your policy.
