@@ -176,6 +176,49 @@ test('browser_take_screenshot (default type should be png)', async ({ startClien
176176 expect ( files [ 0 ] ) . toMatch ( / ^ p a g e - \d { 4 } - \d { 2 } - \d { 2 } T \d { 2 } - \d { 2 } - \d { 2 } - \d { 3 } Z \. p n g $ / ) ;
177177} ) ;
178178
179+ test ( 'browser_take_screenshot (filename is empty string)' , async ( { startClient, server } , testInfo ) => {
180+ const outputDir = testInfo . outputPath ( 'output' ) ;
181+ const { client } = await startClient ( {
182+ config : { outputDir } ,
183+ } ) ;
184+ expect ( await client . callTool ( {
185+ name : 'browser_navigate' ,
186+ arguments : { url : server . HELLO_WORLD } ,
187+ } ) ) . toHaveResponse ( {
188+ code : expect . stringContaining ( `page.goto('http://localhost` ) ,
189+ } ) ;
190+
191+ expect ( await client . callTool ( {
192+ name : 'browser_take_screenshot' ,
193+ arguments : {
194+ filename : '' ,
195+ } ,
196+ } ) ) . toEqual ( {
197+ content : [
198+ {
199+ text : expect . stringMatching (
200+ new RegExp ( `page-\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d{2}\\-\\d{3}Z\\.png` )
201+ ) ,
202+ type : 'text' ,
203+ } ,
204+ {
205+ data : expect . any ( String ) ,
206+ mimeType : 'image/png' ,
207+ type : 'image' ,
208+ } ,
209+ ] ,
210+ } ) ;
211+
212+ const files = [ ...fs . readdirSync ( outputDir ) ] . filter ( f => f . endsWith ( '.png' ) ) ;
213+
214+ expect ( fs . existsSync ( outputDir ) ) . toBeTruthy ( ) ;
215+ expect ( files ) . toHaveLength ( 1 ) ;
216+ expect ( files [ 0 ] ) . toMatch (
217+ new RegExp ( `^page-\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d{2}-\\d{3}Z\\.png$` )
218+ ) ;
219+ } ) ;
220+
221+
179222test ( 'browser_take_screenshot (filename: "output.png")' , async ( { startClient, server } , testInfo ) => {
180223 const outputDir = testInfo . outputPath ( 'output' ) ;
181224 const { client } = await startClient ( {
0 commit comments