使用pg进行postgre数据库写入的测试
import { afterAll, describe, it, expect } from 'vitest'
import { Pool } from 'pg'
import { db } from './your-db'
describe('createUser', () => {
const pool = new Pool()
afterAll(async () => {
await pool.query('DROP TABLE IF EXISTS users')
...
landay.hashnode.dev1 min read