chore: allow specifying output dir (#285)

Ref: https://github.com/microsoft/playwright-mcp/issues/279
This commit is contained in:
Pavel Feldman
2025-04-28 16:35:33 -07:00
committed by GitHub
parent 6e76d5e550
commit 697a69a8c2
6 changed files with 52 additions and 11 deletions

View File

@@ -14,6 +14,8 @@
* limitations under the License.
*/
import fs from 'fs';
import { test, expect } from './fixtures';
test('browser_take_screenshot (viewport)', async ({ client }) => {
@@ -70,3 +72,24 @@ test('browser_take_screenshot (element)', async ({ client }) => {
],
});
});
test('browser_take_screenshot (outputDir)', async ({ startClient }, testInfo) => {
const outputDir = testInfo.outputPath('output');
const client = await startClient({
config: { outputDir },
});
expect(await client.callTool({
name: 'browser_navigate',
arguments: {
url: 'data:text/html,<html><title>Title</title><body>Hello, world!</body></html>',
},
})).toContainTextContent(`Navigate to data:text/html`);
await client.callTool({
name: 'browser_take_screenshot',
arguments: {},
});
expect(fs.existsSync(outputDir)).toBeTruthy();
expect([...fs.readdirSync(outputDir)]).toHaveLength(1);
});