File tree Expand file tree Collapse file tree 2 files changed +28
-30
lines changed Expand file tree Collapse file tree 2 files changed +28
-30
lines changed Original file line number Diff line number Diff line change 6868 - name : Run Playwright MCP tests
6969 id : run-tests
7070 run : |
71- set +e
7271 sudo -E npm run test:integration -- playwright-mcp.test.ts 2>&1 | tee test-output.log
73- echo "exit_code=$?" >> $GITHUB_OUTPUT
7472 continue-on-error : true
7573
7674 - name : Clean npm cache
8583 npx tsx scripts/ci/generate-test-summary.ts "playwright-mcp.test.ts" "Playwright MCP Tests" test-output.log
8684
8785 - name : Check test results
88- if : always()
89- run : |
90- if [ "${{ steps.run-tests.outputs.exit_code }}" != "0" ]; then
91- echo "Tests failed with exit code ${{ steps.run-tests.outputs.exit_code }}"
92- exit 1
93- fi
86+ if : steps.run-tests.outcome == 'failure'
87+ run : exit 1
9488
9589 - name : Post-test cleanup
9690 if : always()
Original file line number Diff line number Diff line change @@ -40,31 +40,35 @@ describe('Playwright MCP Integration', () => {
4040 } ) ;
4141
4242 test ( 'Test 1: Playwright MCP can navigate to GitHub and verify page title' , async ( ) => {
43- // Create MCP config for playwright
44- const mcpConfig = {
45- mcpServers : {
46- playwright : {
47- type : ' local' ,
48- command : ' docker' ,
49- args : [
50- ' run' ,
51- '-i' ,
52- ' --rm' ,
53- ' --init' ,
54- ' mcr.microsoft.com/playwright/mcp' ,
55- ' --output-dir' ,
56- ' /tmp/gh-aw/mcp-logs/playwright' ,
57- ' --allowed-hosts' ,
58- ' localhost;localhost:*;127.0.0.1;127.0.0.1:*;github.com'
59- ] ,
60- tools : [ '*' ]
61- }
62- }
63- } ;
43+ // Create MCP config for playwright using a heredoc to avoid injection risks
44+ const mcpConfigJson = ` {
45+ " mcpServers" : {
46+ " playwright" : {
47+ " type": " local" ,
48+ " command": " docker" ,
49+ " args" : [
50+ " run" ,
51+ "-i" ,
52+ " --rm" ,
53+ " --init" ,
54+ " mcr.microsoft.com/playwright/mcp" ,
55+ " --output-dir" ,
56+ " /tmp/gh-aw/mcp-logs/playwright" ,
57+ " --allowed-hosts" ,
58+ " localhost;localhost:*;127.0.0.1;127.0.0.1:*;github.com"
59+ ],
60+ " tools" : ["*" ]
61+ }
62+ }
63+ }` ;
6464
6565 // Write MCP config to a temporary file and set up the test
66+ // Using heredoc to safely write the config without shell escaping issues
6667 const result = await runner . runWithSudo (
67- `bash -c "mkdir -p ~/.copilot && echo '${ JSON . stringify ( mcpConfig ) } ' > ~/.copilot/mcp-config.json && cat ~/.copilot/mcp-config.json"` ,
68+ `bash -c 'mkdir -p ~/.copilot && cat > ~/.copilot/mcp-config.json << "MCPEOF"
69+ ${ mcpConfigJson }
70+ MCPEOF
71+ cat ~/.copilot/mcp-config.json'` ,
6872 {
6973 allowDomains : [
7074 'github.com' ,
You can’t perform that action at this time.
0 commit comments