Skip to content

jest --detectLeaks is detecting leaks on the getting started example #967

@felipecrs

Description

@felipecrs

PS: I have read #383, but I'm reopening since no solution was provided there.

Expected Behaviour
Not to leak anything. Deno's test runner won't allow tests to pass if leaks are detected, for example.

Actual Behaviour
Leaks are reported. When using TESTCONTAINERS_RYUK_DISABLED=true, less leaks are reported, though.

Testcontainer Logs

npx jest --detectLeaks
 FAIL  ./customer-repository.test.js
  ● Test suite failed to run

    EXPERIMENTAL FEATURE!
    Your test suite is leaking memory. Please ensure all references are cleaned.

    There is a number of things that can leak memory:
      - Async operations that have not finished (e.g. fs.readFile).
      - Timers not properly mocked (e.g. setInterval, setTimeout).
      - Keeping references to the global scope.

      at onResult (node_modules/@jest/core/build/TestScheduler.js:150:18)
      at node_modules/@jest/core/build/TestScheduler.js:254:19
      at node_modules/emittery/index.js:363:13
          at Array.map (<anonymous>)
      at Emittery.emit (node_modules/emittery/index.js:361:23)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        5.484 s, estimated 17 s
Ran all test suites.

Steps to Reproduce

  1. Setup the getting started example: https://testcontainers.com/guides/getting-started-with-testcontainers-for-nodejs/
  2. npx jest --detectLeaks

Environment Information

  • Operating System: Ubuntu 24.04.2 LTS
  • Docker Version: 28.0.4
  • Node version: 22.14.0
  • Testcontainers version: 10.23.0
  • Jest: 29.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageInvestigation required

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions