Skip to content

Commit 68ea4c4

Browse files
committed
make testcontainers wait until container has stopped
1 parent 9292667 commit 68ea4c4

File tree

1 file changed

+10
-3
lines changed
  • internal-packages/testcontainers/src

1 file changed

+10
-3
lines changed

internal-packages/testcontainers/src/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ const postgresContainer = async (
5353
try {
5454
await use(container);
5555
} finally {
56-
await container.stop();
56+
// WARNING: Testcontainers by default will not wait until the container has stopped. It will simply issue the stop command and return immediately.
57+
// If you need to wait for the container to be stopped, you can provide a timeout. The unit of timeout option here is second
58+
await container.stop({ timeout: 10 });
5759
}
5860
};
5961

@@ -92,7 +94,9 @@ const redisContainer = async (
9294
try {
9395
await use(container);
9496
} finally {
95-
await container.stop();
97+
// WARNING: Testcontainers by default will not wait until the container has stopped. It will simply issue the stop command and return immediately.
98+
// If you need to wait for the container to be stopped, you can provide a timeout. The unit of timeout option here is second
99+
await container.stop({ timeout: 10 });
96100
}
97101
};
98102

@@ -142,7 +146,10 @@ const electricOrigin = async (
142146
try {
143147
await use(origin);
144148
} finally {
145-
await container.stop();
149+
// WARNING: Testcontainers by default will not wait until the container has stopped. It will simply issue the stop command and return immediately.
150+
// If you need to wait for the container to be stopped, you can provide a timeout. The unit of timeout option here is second
151+
152+
await container.stop({ timeout: 10 });
146153
}
147154
};
148155

0 commit comments

Comments
 (0)