@@ -26,6 +26,16 @@ describe("Reaper", { timeout: 120_000 }, () => {
2626 expect ( ( ) => reaper . addComposeProject ( "test-project" ) ) . not . toThrow ( ) ;
2727 } ) ;
2828
29+ it ( "should reuse existing reaper container if one is already running" , async ( ) => {
30+ const reaper = await getReaper ( ) ;
31+ const reaperContainerInfo = ( await client . container . list ( ) ) . filter ( ( c ) => c . Id === reaper . containerId ) [ 0 ] ;
32+ vi . spyOn ( client . container , "list" ) . mockResolvedValue ( [ reaperContainerInfo ] ) ;
33+
34+ const reaper2 = await getReaper ( ) ;
35+
36+ expect ( reaper2 . containerId ) . toBe ( reaper . containerId ) ;
37+ } ) ;
38+
2939 it ( "should use custom port when TESTCONTAINERS_RYUK_PORT is set" , async ( ) => {
3040 const customPort = ( await new RandomUniquePortGenerator ( ) . generatePort ( ) ) . toString ( ) ;
3141 vi . stubEnv ( "TESTCONTAINERS_RYUK_PORT" , customPort ) ;
@@ -38,16 +48,6 @@ describe("Reaper", { timeout: 120_000 }, () => {
3848 expect ( ports [ "8080" ] [ 0 ] . HostPort ) . toBe ( customPort ) ;
3949 } ) ;
4050
41- it ( "should reuse existing reaper container if one is already running" , async ( ) => {
42- const reaper = await getReaper ( ) ;
43- const reaperContainerInfo = ( await client . container . list ( ) ) . filter ( ( c ) => c . Id === reaper . containerId ) [ 0 ] ;
44- vi . spyOn ( client . container , "list" ) . mockResolvedValue ( [ reaperContainerInfo ] ) ;
45-
46- const reaper2 = await getReaper ( ) ;
47-
48- expect ( reaper2 . containerId ) . toBe ( reaper . containerId ) ;
49- } ) ;
50-
5151 it ( "should create Reaper container without RYUK_VERBOSE env var by default" , async ( ) => {
5252 vi . spyOn ( client . container , "list" ) . mockResolvedValue ( [ ] ) ;
5353 const reaper = await getReaper ( ) ;
0 commit comments