Files
supabase/tests/.jest/teardown.ts
egor-romanov 1895bf701e chore: upd integration tests (#9320)
* extend integration test suite and move to v2
* update workflow
* change tests to run against cli setup
2022-10-12 14:50:04 +03:00

26 lines
592 B
TypeScript

import { createClient, User, UserResponse } from '@supabase/supabase-js'
const removeAllUsers = async () => {
const sb = createClient(
process.env.SUPABASE_URL as string,
process.env.SUPABASE_KEY_ADMIN as string
)
const {
data: { users },
} = await sb.auth.admin.listUsers()
const promises: Promise<UserResponse>[] = []
users.map((u) => {
sb.from('profiles')
.delete()
.match({ id: u.id })
.then(() => promises.push(sb.auth.admin.deleteUser(u.id)))
})
await Promise.all(promises)
}
export default async () => {
await removeAllUsers()
}