@@ -10,7 +10,9 @@ import {readFile} from '@shopify/cli-kit/node/fs'
1010import { describe , expect , beforeAll , test , vi } from 'vitest'
1111import { AbortError } from '@shopify/cli-kit/node/error'
1212import { outputInfo } from '@shopify/cli-kit/node/output'
13- import { readdirSync } from 'fs'
13+ import { getLogsDir } from '@shopify/cli-kit/node/logs'
14+
15+ import { existsSync , readdirSync } from 'fs'
1416
1517vi . mock ( 'fs' )
1618vi . mock ( '@shopify/cli-kit/node/fs' )
@@ -111,6 +113,24 @@ describe('replay', () => {
111113
112114 test ( 'throws error if no logs available' , async ( ) => {
113115 // Given
116+ mockFileOperations ( [ ] )
117+
118+ // When/Then
119+ await expect ( async ( ) => {
120+ await replay ( {
121+ app : testAppLinked ( ) ,
122+ extension,
123+ stdout : false ,
124+ path : 'test-path' ,
125+ json : true ,
126+ watch : false ,
127+ } )
128+ } ) . rejects . toThrow ( new AbortError ( `No logs found in ${ getLogsDir ( ) } ` ) )
129+ } )
130+
131+ test ( 'throws error if log directory does not exist' , async ( ) => {
132+ // Given
133+ vi . mocked ( existsSync ) . mockReturnValue ( false )
114134
115135 // When/Then
116136 await expect ( async ( ) => {
@@ -122,7 +142,7 @@ describe('replay', () => {
122142 json : true ,
123143 watch : false ,
124144 } )
125- } ) . rejects . toThrow ( )
145+ } ) . rejects . toThrow ( new AbortError ( `No logs found in ${ getLogsDir ( ) } ` ) )
126146 } )
127147
128148 test ( 'delegates to renderReplay when watch is true' , async ( ) => {
@@ -285,6 +305,7 @@ function expectFunctionRun(functionExtension: ExtensionInstance<FunctionConfigTy
285305}
286306
287307function mockFileOperations ( data : { run : FunctionRunData ; path : string } [ ] ) {
308+ vi . mocked ( existsSync ) . mockReturnValue ( true )
288309 vi . mocked ( readdirSync ) . mockReturnValue ( [ ...data ] . reverse ( ) . map ( ( { path} ) => path ) as any )
289310 vi . mocked ( readFile ) . mockImplementation ( ( path ) => {
290311 const run = data . find ( ( file ) => path . endsWith ( file . path ) )
0 commit comments