generated at
Testcontainers





これのコード片読んで雰囲気が掴めた
ts
test("account", async () => { // コンテナ作成 const container = await new GenericContainer("postgres:latest").. // クライアント作成 const client = new Client({..}); await client.connect(); await client.query("SELECT 1"); // sqlを取得して、スキーマを作る const schemaSQL = fs.readFileSync("db/schema.sql", "utf-8"); await client.query(schemaSQL); // 良い感じにデータを埋めて準備完了 await createAccount(client, {...}); // あとは取得する関数を呼んだりしてテストする const account = await getAccount(client, { id: "spam" }); expect(account).... // 後始末など await client.end(); await container.stop(); }, 30_000);