Skip to content

Commit dded5ff

Browse files
author
Paul Marbach
authored
Merge pull request #30 from cristianrgreco/patch-1
Use testcontainers' default wait strategy which waits for port
2 parents 7e49de8 + 58f9f5c commit dded5ff

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

src/jest/global_setup.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
import { Duration, TemporalUnit } from 'node-duration';
17-
import { GenericContainer, Wait, StartedTestContainer } from 'testcontainers';
17+
import { GenericContainer, StartedTestContainer } from 'testcontainers';
1818
import { Pool } from 'pg';
1919

2020
import logger from '../logger';
@@ -40,18 +40,8 @@ export default async () => {
4040
.withEnv('POSTGRES_USER', 'postgres')
4141
.withEnv('POSTGRES_PASSWORD', 'postgres')
4242
.withEnv('POSTGRES_DB', 'postgres')
43-
.withWaitStrategy(
44-
Wait.forLogMessage('listening on IPv4 address "0.0.0.0", port 5432'),
45-
)
4643
.start();
4744

48-
// The postgres docker container prints that it's ready for connections twice, so we
49-
// have to listen for another log line. However, this log message comes before the
50-
// container is actually ready, so we need to wait a little.
51-
await new Promise(resolve => {
52-
setTimeout(resolve, 3000);
53-
});
54-
5545
// We have to use global setup because it's the only way in Jest to run code once before suite.
5646
// Unfortuantely Jest prevents us from writing globals that are read by the sutite.
5747
// So, we are forced to write the connection info to the ENV.

0 commit comments

Comments
 (0)