-
I am trying to use this package for some integration tests but I am getting really flaky results. It seems to have to do with the package manager that is in use (I'm currently using Yarn V3, but I tried V1 as well), and I was hoping that maybe someone has an idea as to what might be going wrong. The project is built using Nest.js, and the testing framework in use is Jest. However, I have been able to get the same issue without touching any Nestjs components. Configuration/Setup
{
"preset": "ts-jest",
"roots": ["test"],
"testRegex": ".(spec|test).ts$",
"collectCoverageFrom": [
"**/*.(t|j)s",
"!src/main.ts",
"!src/db/migrations/*.ts"
],
"coverageDirectory": "coverage",
"testEnvironment": "node"
}
import 'reflect-metadata'
import { PostgreSqlContainer, StartedPostgreSqlContainer } from 'testcontainers'
jest.setTimeout(180_000)
describe('Example integration test', () => {
let pgContainer: StartedPostgreSqlContainer
beforeAll(async () => {
pgContainer = await new PostgreSqlContainer().start()
})
afterAll(async () => {
await pgContainer.stop()
})
it('successfully wastes time', () => {
expect(1 + 1).toBe(2)
})
}) Result / Test outputYarn V3 & V1About 95% of test runs end up like this. Every now and then, I get a successful test.
PASS test/example-integration.spec.ts (14.678 s)
Example integration test
√ successfully wastes time (2 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 14.774 s, estimated 15 s
Ran all test suites.
Jest has detected the following 6 open handles potentially keeping Jest from exiting:
● RANDOMBYTESREQUEST
at RandomUuid.nextUuid (node_modules/testcontainers/dist/uuid.js:10:33)
at Object.<anonymous> (node_modules/testcontainers/dist/docker/session-id.js:5:45)
at Object.<anonymous> (node_modules/testcontainers/dist/reaper.js:16:22)
● SIGNREQUEST
at node_modules/ssh2/lib/protocol/constants.js:22:20
at Object.<anonymous> (node_modules/ssh2/lib/protocol/constants.js:29:3)
at Object.<anonymous> (node_modules/ssh2/lib/protocol/keyParser.js:24:46)
● SIGNREQUEST
at node_modules/ssh2/lib/protocol/constants.js:23:25
at Object.<anonymous> (node_modules/ssh2/lib/protocol/constants.js:29:3)
at Object.<anonymous> (node_modules/ssh2/lib/protocol/keyParser.js:24:46)
● ZLIB
at Object.<anonymous> (node_modules/ssh2/lib/protocol/zlib.js:17:20)
at Object.<anonymous> (node_modules/ssh2/lib/protocol/kex.js:48:5)
● RANDOMBYTESREQUEST
9 |
10 | beforeAll(async () => {
> 11 | pgContainer = await new PostgreSqlContainer().start()
| ^
12 | })
13 |
14 | afterAll(async () => {
at RandomUuid.nextUuid (node_modules/testcontainers/dist/uuid.js:10:33)
at new PostgreSqlContainer (node_modules/testcontainers/dist/modules/postgresql/postgresql-container.js:20:49)
at Object.<anonymous> (test/example-integration.spec.ts:11:25)
● RANDOMBYTESREQUEST
9 |
10 | beforeAll(async () => {
> 11 | pgContainer = await new PostgreSqlContainer().start()
| ^
12 | })
13 |
14 | afterAll(async () => {
at RandomUuid.nextUuid (node_modules/testcontainers/dist/uuid.js:10:33)
at new PostgreSqlContainer (node_modules/testcontainers/dist/modules/postgresql/postgresql-container.js:21:49)
at Object.<anonymous> (test/example-integration.spec.ts:11:25) NPMWhen running using NPM, the test works as expected every time!
PASS test/example-integration.spec.ts (11.138 s)
Example integration test
√ successfully wastes time (1 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 11.23 s, estimated 20 s |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 14 replies
-
Hi @SkySails I just searched for that error and it seems to be an issue with Jest: Found here: https://stackoverflow.com/questions/65653226/jest-and-randombytesrequest-open-handles The solution is to upgrade Jest version to >= |
Beta Was this translation helpful? Give feedback.
-
It looks like this was fixed in jestjs/jest#12789, thanks to @cristianrgreco ! I can no longer reproduce the original issue! 🎉 |
Beta Was this translation helpful? Give feedback.
It looks like this was fixed in jestjs/jest#12789, thanks to @cristianrgreco ! I can no longer reproduce the original issue! 🎉