-
-
Notifications
You must be signed in to change notification settings - Fork 251
Description
Hey, I'm using withReuse to re-use my containers between test runs, and it works fine when tests run serially in the same node process.
But, with test runners like node:test, each test file runs in a different node process, and it seems that the containers are not reused correctly in this case.
If I understand the code correctly, the reuse feature is based on a in-memory lock, so it makes sense that the feature doesn't work with parallel execution.
I've done a minimal reproduction here.
Expected Behaviour
Containers configured with .withReuse should be re-used, even when started from two different nodejs processes.
Actual Behaviour
Containers configured with .withReuse are not reused when the tests are running in different nodejs processes.
If two test files are defined, and each file starts the re-used container, then the container will be started twice.
Testcontainer Logs
...
Steps to Reproduce
The steps are in the reproduction repository
Environment Information
- Operating System: macOS Sequoia 15.6.1
- Docker Version: Docker version 28.3.2, build 578ccf6
- Node version: v24.10.0
- Testcontainers version: 11.7.2