@@ -525,10 +525,11 @@ describe("GenericContainer", { timeout: 180_000 }, () => {
525525 . withAutoRemove ( false )
526526 . start ( ) ;
527527
528- await container . stop ( ) ;
529-
530- expect ( await getRunningContainerNames ( ) ) . not . toContain ( container . getName ( ) . replace ( "/" , "" ) ) ;
531- expect ( await getStoppedContainerNames ( ) ) . toContain ( container . getName ( ) . replace ( "/" , "" ) ) ;
528+ const stopped = await container . stop ( ) ;
529+ const dockerode = ( await getContainerRuntimeClient ( ) ) . container . dockerode ;
530+ expect ( stopped . getId ( ) ) . toBeTruthy ( ) ;
531+ const lowerLevelContainer = dockerode . getContainer ( stopped . getId ( ) ) ;
532+ expect ( ( await lowerLevelContainer . inspect ( ) ) . State . Status ) . toEqual ( "exited" ) ;
532533 } ) ;
533534
534535 it ( "should stop and override .withAutoRemove" , async ( ) => {
@@ -539,8 +540,11 @@ describe("GenericContainer", { timeout: 180_000 }, () => {
539540
540541 await container . stop ( { remove : true } ) ;
541542
542- expect ( await getRunningContainerNames ( ) ) . not . toContain ( container . getName ( ) . replace ( "/" , "" ) ) ;
543- expect ( await getStoppedContainerNames ( ) ) . not . toContain ( container . getName ( ) . replace ( "/" , "" ) ) ;
543+ const stopped = await container . stop ( ) ;
544+ const dockerode = ( await getContainerRuntimeClient ( ) ) . container . dockerode ;
545+ expect ( stopped . getId ( ) ) . toBeTruthy ( ) ;
546+ const lowerLevelContainer = dockerode . getContainer ( stopped . getId ( ) ) ;
547+ await expect ( lowerLevelContainer . inspect ( ) ) . rejects . toThrow ( / 4 0 4 / ) // Error: (HTTP code 404) no such container
544548 } ) ;
545549
546550 it ( "should build a target stage" , async ( ) => {
0 commit comments