- tests/db: PGlite (PostgreSQL 17 WASM) applies the Supabase shim + migrations and runs supabase/tests/*.sql through pgTAP without Docker - schema-types test pins tables, columns, enums, RPC args, RLS-on, no using(true) - database.types.ts in supabase gen types format; createBrowserClient (PKCE) - Supabase CLI pinned as root devDependency; db:* root scripts
37 lines
973 B
TypeScript
37 lines
973 B
TypeScript
/**
|
|
* Runs every pgTAP file under supabase/tests against a migrated PGlite
|
|
* database. One vitest case per SQL file: the failing TAP lines are the
|
|
* assertion message, so a red test names the exact pgTAP check.
|
|
*/
|
|
import type { PGlite } from '@electric-sql/pglite'
|
|
import {
|
|
createMigratedDatabase,
|
|
listPgTapTests,
|
|
runPgTapFile,
|
|
} from './harness'
|
|
|
|
const files = await listPgTapTests()
|
|
|
|
describe('pgTAP suite (supabase/tests) on PGlite', () => {
|
|
let db: PGlite
|
|
|
|
beforeAll(async () => {
|
|
db = await createMigratedDatabase()
|
|
})
|
|
|
|
afterAll(async () => {
|
|
await db?.close()
|
|
})
|
|
|
|
it('finds at least one pgTAP file', () => {
|
|
expect(files.length).toBeGreaterThan(0)
|
|
})
|
|
|
|
it.each(files)('%s passes', async (file) => {
|
|
const report = await runPgTapFile(db, file)
|
|
const okCount = report.lines.filter((l) => /^ok\b/.test(l)).length
|
|
expect(report.failures, report.lines.join('\n')).toEqual([])
|
|
expect(okCount).toBeGreaterThan(0)
|
|
})
|
|
})
|