Conflict error when running multiple Jest tests using DockerComposeEnvironment
in testcontainers-node
#10479
-
I'm currently using I'm calling I initially assumed this setup would run once globally for the entire test suite. However, since setupFilesAfterEnv runs in the context of each test file, this beforeAll() block is actually executed once per test file — leading to multiple attempts to spin up the same Docker Compose environment. As a result, when running multiple test files concurrently (e.g., via jest with no specific file passed), I encounter this Docker error:
It seems like multiple tests try to spin up the same container (with the same name), leading to a conflict. I've looked at this part of the docs: I suspect the issue is due to I'm wondering:
Has anyone run into this or found a best practice for test isolation in this context? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The solution is to use |
Beta Was this translation helpful? Give feedback.
The solution is to use
globalSetup
andglobalTeardown
configuration in Jest.