Leave TLS connection open in between tests
When I have 2 tests that use a database connection and attempt to close the connection
results in
Thanks in advance!
afterAllafterAll the tests, the first fails because there's an open tls connection. Is it possible to leave the connection is open at the end of the first test?import { afterAll, describe, it } from 'std/testing/bdd.ts'
import { assertEquals } from 'std/testing/asserts.ts'
import db from '../../db/db.ts'
import { sql } from "kysely"
describe('db/models/foo.ts', () => {
afterAll(() => db.destroy())
it('does something', async () => {
const result = await db.selectNoFrom(eb => [sql`1 + 1`.as('result')]).executeTakeFirst()
assertEquals(result, { result: 2 })
})
it('does something else', async () => {
const result = await db.selectNoFrom(eb => [sql`2 + 2`.as('result')]).executeTakeFirst()
assertEquals(result, { result: 4 })
})
})import { afterAll, describe, it } from 'std/testing/bdd.ts'
import { assertEquals } from 'std/testing/asserts.ts'
import db from '../../db/db.ts'
import { sql } from "kysely"
describe('db/models/foo.ts', () => {
afterAll(() => db.destroy())
it('does something', async () => {
const result = await db.selectNoFrom(eb => [sql`1 + 1`.as('result')]).executeTakeFirst()
assertEquals(result, { result: 2 })
})
it('does something else', async () => {
const result = await db.selectNoFrom(eb => [sql`2 + 2`.as('result')]).executeTakeFirst()
assertEquals(result, { result: 4 })
})
})results in
deno task test test/models/foo.test.ts
Task test DENO_TLS_CA_STORE=system IS_TEST=true deno test -A --unsafely-ignore-certificate-errors "test/models/foo.test.ts"
DANGER: TLS certificate validation is disabled for all hostnames
Check file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/test/models/foo.test.ts
running 1 test from ./test/models/foo.test.ts
db/models/foo.ts ...
does something ... FAILED (21ms)
does something else ... ok (4ms)
db/models/foo.ts ... FAILED (due to 1 failed step) (31ms)
ERRORS
db/models/foo.ts ... does something => https://deno.land/std@0.190.0/testing/_test_suite.ts:323:15
error: Leaking resources:
- A TCP connection (rid 3) was opened/accepted during the test, but not closed during the test. Close the TCP connection by calling `tcpConn.close()`.
FAILURES
db/models/foo.ts ... does something => https://deno.land/std@0.190.0/testing/_test_suite.ts:323:15
FAILED | 0 passed (1 step) | 1 failed (1 step) (99ms)
error: Test faileddeno task test test/models/foo.test.ts
Task test DENO_TLS_CA_STORE=system IS_TEST=true deno test -A --unsafely-ignore-certificate-errors "test/models/foo.test.ts"
DANGER: TLS certificate validation is disabled for all hostnames
Check file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/test/models/foo.test.ts
running 1 test from ./test/models/foo.test.ts
db/models/foo.ts ...
does something ... FAILED (21ms)
does something else ... ok (4ms)
db/models/foo.ts ... FAILED (due to 1 failed step) (31ms)
ERRORS
db/models/foo.ts ... does something => https://deno.land/std@0.190.0/testing/_test_suite.ts:323:15
error: Leaking resources:
- A TCP connection (rid 3) was opened/accepted during the test, but not closed during the test. Close the TCP connection by calling `tcpConn.close()`.
FAILURES
db/models/foo.ts ... does something => https://deno.land/std@0.190.0/testing/_test_suite.ts:323:15
FAILED | 0 passed (1 step) | 1 failed (1 step) (99ms)
error: Test failedThanks in advance!
