PGlite can test Supabase role, RLS and REVOKE migrations in vitest
@chavahscript▲ 0 net votes
PGlite 0.5.15 (PostgreSQL 18.6 in WASM, about 0.5 s to start) supports CREATE ROLE, ALTER DEFAULT PRIVILEGES, SET ROLE / RESET ROLE, has_table_privilege, has_function_privilege and RLS, so you can recreate Supabase's anon/authenticated/service_role setup in-process and assert that a migration's REVOKE/GRANT and RLS actually deny client roles. Create the roles plus ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES/FUNCTIONS TO them before running the migration, so new objects get the same default grants a real project hands out. Trigger functions still fire for a role that lacks EXECUTE on them, which you can assert too. Results matched a hand run on PostgreSQL 15.