@@ -10,6 +10,7 @@ import {
1010 getRunningContainerNames ,
1111 waitForDockerEvent ,
1212} from "../utils/test-helper" ;
13+ import { Wait } from "../wait-strategies/wait" ;
1314import { GenericContainer } from "./generic-container" ;
1415
1516describe ( "GenericContainer" , { timeout : 180_000 } , ( ) => {
@@ -24,9 +25,14 @@ describe("GenericContainer", { timeout: 180_000 }, () => {
2425 } ) ;
2526
2627 it ( "should return first mapped port with regardless of protocol" , async ( ) => {
27- await using container = await new GenericContainer ( "mendhak/udp-listener" ) . withExposedPorts ( "5005/udp" ) . start ( ) ;
28+ await using container = await new GenericContainer ( "mendhak/udp-listener" )
29+ . withWaitStrategy ( Wait . forLogMessage ( "Listening on UDP port 5005" ) )
30+ . withExposedPorts ( "5005/udp" )
31+ . start ( ) ;
32+
2833 await checkContainerIsHealthyUdp ( container ) ;
2934 expect ( container . getFirstMappedPort ( ) ) . toBe ( container . getMappedPort ( "5005/udp" ) ) ;
35+ expect ( container . getFirstMappedPort ( ) ) . toBe ( container . getMappedPort ( 5005 , "udp" ) ) ;
3036 } ) ;
3137
3238 it ( "should bind to specified host port" , async ( ) => {
@@ -45,12 +51,14 @@ describe("GenericContainer", { timeout: 180_000 }, () => {
4551 it ( "should bind to specified host port with a different protocol" , async ( ) => {
4652 const hostPort = await getPort ( ) ;
4753 await using container = await new GenericContainer ( "mendhak/udp-listener" )
54+ . withWaitStrategy ( Wait . forLogMessage ( "Listening on UDP port 5005" ) )
4855 . withExposedPorts ( {
4956 container : 5005 ,
5057 host : hostPort ,
5158 protocol : "udp" ,
5259 } )
5360 . start ( ) ;
61+
5462 await checkContainerIsHealthyUdp ( container ) ;
5563 expect ( container . getMappedPort ( "5005/udp" ) ) . toBe ( hostPort ) ;
5664 expect ( container . getMappedPort ( 5005 , "udp" ) ) . toBe ( hostPort ) ;
0 commit comments