Closed sombriks closed 3 months ago
I am using ava combined with testcontainers so i can avoid sqlite and dialect issues for a sample app consuming postgresql.
I have proper test.before and test.after.always hooks, since i plan to keep the database container alive until the end of the test suite:
test.before
test.after.always
// imports test.before(async t => { t.context.postgres = await new PostgreSqlContainer('postgres:16.3-alpine3.20') .withDatabase(process.env.PG_DATABASE) .withUsername(process.env.PG_USERNAME) .withPassword(process.env.PG_PASSWORD) .withBindMounts([{ source: resolve('../sample-kanban-jvm/src/test/resources/initial-state.sql'), target: '/docker-entrypoint-initdb.d/init.sql', }]) .start(); t.context.db = prepareDatabase(t.context.postgres.getConnectionUri()); const {app} = prepareApp({db: t.context.db}); t.context.callback = app.callback(); }); test.after.always(async t => { await t.context.db.destroy(); await t.context.postgres.stop({timeout: 500}); }); // test cases
It is however hanging and ending with timeout, even with all tests being successful.
Please check the full sample code here.
False alarm, i was using the live postgres container instead of the testcontainer one. sample code corrected, if it worth anything
I am using ava combined with testcontainers so i can avoid sqlite and dialect issues for a sample app consuming postgresql.
I have proper
test.before
andtest.after.always
hooks, since i plan to keep the database container alive until the end of the test suite:It is however hanging and ending with timeout, even with all tests being successful.
Please check the full sample code here.