@browserstack/mcp-server 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +88 -2
  2. package/dist/lib/device-cache.js +20 -17
  3. package/dist/lib/inmemory-store.d.ts +1 -0
  4. package/dist/lib/inmemory-store.js +1 -0
  5. package/dist/lib/utils.d.ts +5 -0
  6. package/dist/lib/utils.js +27 -0
  7. package/dist/server-factory.js +6 -0
  8. package/dist/tools/add-percy-snapshots.d.ts +5 -0
  9. package/dist/tools/add-percy-snapshots.js +17 -0
  10. package/dist/tools/appautomate-utils/appium-sdk/config-generator.d.ts +1 -0
  11. package/dist/tools/appautomate-utils/appium-sdk/config-generator.js +50 -0
  12. package/dist/tools/appautomate-utils/appium-sdk/constants.d.ts +23 -0
  13. package/dist/tools/appautomate-utils/appium-sdk/constants.js +43 -0
  14. package/dist/tools/appautomate-utils/appium-sdk/formatter.d.ts +8 -0
  15. package/dist/tools/appautomate-utils/appium-sdk/formatter.js +59 -0
  16. package/dist/tools/appautomate-utils/appium-sdk/handler.d.ts +3 -0
  17. package/dist/tools/appautomate-utils/appium-sdk/handler.js +52 -0
  18. package/dist/tools/appautomate-utils/appium-sdk/index.d.ts +7 -0
  19. package/dist/tools/appautomate-utils/appium-sdk/index.js +8 -0
  20. package/dist/tools/appautomate-utils/appium-sdk/instructions.d.ts +3 -0
  21. package/dist/tools/appautomate-utils/appium-sdk/instructions.js +47 -0
  22. package/dist/tools/appautomate-utils/appium-sdk/languages/csharp.d.ts +2 -0
  23. package/dist/tools/appautomate-utils/appium-sdk/languages/csharp.js +78 -0
  24. package/dist/tools/appautomate-utils/appium-sdk/languages/java.d.ts +8 -0
  25. package/dist/tools/appautomate-utils/appium-sdk/languages/java.js +87 -0
  26. package/dist/tools/appautomate-utils/appium-sdk/languages/nodejs.d.ts +3 -0
  27. package/dist/tools/appautomate-utils/appium-sdk/languages/nodejs.js +194 -0
  28. package/dist/tools/appautomate-utils/appium-sdk/languages/python.d.ts +3 -0
  29. package/dist/tools/appautomate-utils/appium-sdk/languages/python.js +76 -0
  30. package/dist/tools/appautomate-utils/appium-sdk/languages/ruby.d.ts +2 -0
  31. package/dist/tools/appautomate-utils/appium-sdk/languages/ruby.js +85 -0
  32. package/dist/tools/appautomate-utils/appium-sdk/types.d.ts +57 -0
  33. package/dist/tools/appautomate-utils/appium-sdk/types.js +54 -0
  34. package/dist/tools/appautomate-utils/appium-sdk/utils.d.ts +17 -0
  35. package/dist/tools/appautomate-utils/appium-sdk/utils.js +64 -0
  36. package/dist/tools/appautomate-utils/{appautomate.d.ts → native-execution/appautomate.d.ts} +1 -1
  37. package/dist/tools/appautomate-utils/{appautomate.js → native-execution/appautomate.js} +2 -2
  38. package/dist/tools/appautomate-utils/native-execution/constants.d.ts +10 -0
  39. package/dist/tools/appautomate-utils/native-execution/constants.js +36 -0
  40. package/dist/tools/appautomate-utils/native-execution/types.d.ts +19 -0
  41. package/dist/tools/appautomate-utils/{types.js → native-execution/types.js} +5 -1
  42. package/dist/tools/appautomate.js +25 -40
  43. package/dist/tools/bstack-sdk.d.ts +2 -15
  44. package/dist/tools/bstack-sdk.js +10 -119
  45. package/dist/tools/build-insights.d.ts +7 -0
  46. package/dist/tools/build-insights.js +67 -0
  47. package/dist/tools/list-test-files.d.ts +2 -0
  48. package/dist/tools/list-test-files.js +36 -0
  49. package/dist/tools/percy-sdk.d.ts +4 -0
  50. package/dist/tools/percy-sdk.js +71 -0
  51. package/dist/tools/percy-snapshot-utils/constants.d.ts +16 -0
  52. package/dist/tools/percy-snapshot-utils/constants.js +500 -0
  53. package/dist/tools/percy-snapshot-utils/detect-test-files.d.ts +10 -0
  54. package/dist/tools/percy-snapshot-utils/detect-test-files.js +175 -0
  55. package/dist/tools/percy-snapshot-utils/types.d.ts +15 -0
  56. package/dist/tools/percy-snapshot-utils/utils.d.ts +4 -0
  57. package/dist/tools/percy-snapshot-utils/utils.js +30 -0
  58. package/dist/tools/rca-agent-utils/constants.d.ts +13 -0
  59. package/dist/tools/rca-agent-utils/constants.js +24 -0
  60. package/dist/tools/rca-agent-utils/format-rca.d.ts +1 -0
  61. package/dist/tools/rca-agent-utils/format-rca.js +37 -0
  62. package/dist/tools/rca-agent-utils/get-build-id.d.ts +1 -0
  63. package/dist/tools/rca-agent-utils/get-build-id.js +18 -0
  64. package/dist/tools/rca-agent-utils/get-failed-test-id.d.ts +2 -0
  65. package/dist/tools/rca-agent-utils/get-failed-test-id.js +69 -0
  66. package/dist/tools/rca-agent-utils/rca-data.d.ts +9 -0
  67. package/dist/tools/rca-agent-utils/rca-data.js +196 -0
  68. package/dist/tools/rca-agent-utils/types.d.ts +48 -0
  69. package/dist/tools/rca-agent-utils/types.js +20 -0
  70. package/dist/tools/rca-agent.d.ts +14 -0
  71. package/dist/tools/rca-agent.js +119 -0
  72. package/dist/tools/review-agent-utils/build-counts.d.ts +7 -0
  73. package/dist/tools/review-agent-utils/build-counts.js +44 -0
  74. package/dist/tools/review-agent-utils/percy-approve-reject.d.ts +6 -0
  75. package/dist/tools/review-agent-utils/percy-approve-reject.js +39 -0
  76. package/dist/tools/review-agent-utils/percy-diffs.d.ts +9 -0
  77. package/dist/tools/review-agent-utils/percy-diffs.js +35 -0
  78. package/dist/tools/review-agent-utils/percy-snapshots.d.ts +11 -0
  79. package/dist/tools/review-agent-utils/percy-snapshots.js +58 -0
  80. package/dist/tools/review-agent.d.ts +5 -0
  81. package/dist/tools/review-agent.js +56 -0
  82. package/dist/tools/run-percy-scan.d.ts +8 -0
  83. package/dist/tools/run-percy-scan.js +37 -0
  84. package/dist/tools/sdk-utils/{commands.d.ts → bstack/commands.d.ts} +1 -1
  85. package/dist/tools/sdk-utils/bstack/commands.js +88 -0
  86. package/dist/tools/sdk-utils/bstack/configUtils.d.ts +4 -0
  87. package/dist/tools/sdk-utils/bstack/configUtils.js +66 -0
  88. package/dist/tools/sdk-utils/bstack/constants.d.ts +58 -0
  89. package/dist/tools/sdk-utils/{constants.js → bstack/constants.js} +117 -78
  90. package/dist/tools/sdk-utils/{constants.d.ts → bstack/frameworks.d.ts} +1 -1
  91. package/dist/tools/sdk-utils/bstack/frameworks.js +57 -0
  92. package/dist/tools/sdk-utils/bstack/index.d.ts +4 -0
  93. package/dist/tools/sdk-utils/bstack/index.js +5 -0
  94. package/dist/tools/sdk-utils/bstack/sdkHandler.d.ts +4 -0
  95. package/dist/tools/sdk-utils/bstack/sdkHandler.js +74 -0
  96. package/dist/tools/sdk-utils/common/constants.d.ts +10 -0
  97. package/dist/tools/sdk-utils/common/constants.js +86 -0
  98. package/dist/tools/sdk-utils/common/formatUtils.d.ts +5 -0
  99. package/dist/tools/sdk-utils/common/formatUtils.js +27 -0
  100. package/dist/tools/sdk-utils/common/index.d.ts +3 -0
  101. package/dist/tools/sdk-utils/common/index.js +4 -0
  102. package/dist/tools/sdk-utils/common/instructionUtils.d.ts +8 -0
  103. package/dist/tools/sdk-utils/common/instructionUtils.js +20 -0
  104. package/dist/tools/sdk-utils/common/schema.d.ts +73 -0
  105. package/dist/tools/sdk-utils/common/schema.js +51 -0
  106. package/dist/tools/sdk-utils/common/types.d.ts +66 -0
  107. package/dist/tools/sdk-utils/{types.js → common/types.js} +15 -2
  108. package/dist/tools/sdk-utils/common/utils.d.ts +25 -0
  109. package/dist/tools/sdk-utils/common/utils.js +90 -0
  110. package/dist/tools/sdk-utils/handler.d.ts +4 -0
  111. package/dist/tools/sdk-utils/handler.js +119 -0
  112. package/dist/tools/sdk-utils/percy-automate/constants.d.ts +11 -0
  113. package/dist/tools/sdk-utils/percy-automate/constants.js +338 -0
  114. package/dist/tools/sdk-utils/percy-automate/frameworks.d.ts +8 -0
  115. package/dist/tools/sdk-utils/percy-automate/frameworks.js +50 -0
  116. package/dist/tools/sdk-utils/percy-automate/handler.d.ts +3 -0
  117. package/dist/tools/sdk-utils/percy-automate/handler.js +30 -0
  118. package/dist/tools/sdk-utils/percy-automate/index.d.ts +1 -0
  119. package/dist/tools/sdk-utils/percy-automate/index.js +2 -0
  120. package/dist/tools/sdk-utils/percy-automate/types.d.ts +13 -0
  121. package/dist/tools/sdk-utils/percy-automate/types.js +1 -0
  122. package/dist/tools/sdk-utils/percy-bstack/constants.d.ts +4 -0
  123. package/dist/tools/sdk-utils/{percy → percy-bstack}/constants.js +13 -39
  124. package/dist/tools/sdk-utils/percy-bstack/frameworks.d.ts +2 -0
  125. package/dist/tools/sdk-utils/percy-bstack/frameworks.js +27 -0
  126. package/dist/tools/sdk-utils/percy-bstack/handler.d.ts +4 -0
  127. package/dist/tools/sdk-utils/percy-bstack/handler.js +99 -0
  128. package/dist/tools/sdk-utils/percy-bstack/index.d.ts +4 -0
  129. package/dist/tools/sdk-utils/percy-bstack/index.js +4 -0
  130. package/dist/tools/sdk-utils/percy-bstack/instructions.d.ts +7 -0
  131. package/dist/tools/sdk-utils/{percy → percy-bstack}/instructions.js +5 -9
  132. package/dist/tools/sdk-utils/percy-bstack/types.d.ts +13 -0
  133. package/dist/tools/sdk-utils/percy-bstack/types.js +5 -0
  134. package/dist/tools/sdk-utils/percy-web/constants.d.ts +41 -0
  135. package/dist/tools/sdk-utils/percy-web/constants.js +883 -0
  136. package/dist/tools/sdk-utils/percy-web/fetchPercyToken.d.ts +4 -0
  137. package/dist/tools/sdk-utils/percy-web/fetchPercyToken.js +32 -0
  138. package/dist/tools/sdk-utils/percy-web/frameworks.d.ts +7 -0
  139. package/dist/tools/sdk-utils/percy-web/frameworks.js +103 -0
  140. package/dist/tools/sdk-utils/percy-web/handler.d.ts +4 -0
  141. package/dist/tools/sdk-utils/percy-web/handler.js +27 -0
  142. package/dist/tools/sdk-utils/percy-web/index.d.ts +4 -0
  143. package/dist/tools/sdk-utils/percy-web/index.js +4 -0
  144. package/dist/tools/sdk-utils/percy-web/types.d.ts +12 -0
  145. package/dist/tools/sdk-utils/percy-web/types.js +1 -0
  146. package/dist/tools/testmanagement-utils/create-testrun.d.ts +4 -4
  147. package/dist/tools/testmanagement-utils/update-testrun.d.ts +4 -4
  148. package/package.json +2 -1
  149. package/dist/tools/appautomate-utils/types.d.ts +0 -5
  150. package/dist/tools/sdk-utils/commands.js +0 -65
  151. package/dist/tools/sdk-utils/instructions.d.ts +0 -6
  152. package/dist/tools/sdk-utils/instructions.js +0 -99
  153. package/dist/tools/sdk-utils/percy/constants.d.ts +0 -3
  154. package/dist/tools/sdk-utils/percy/instructions.d.ts +0 -10
  155. package/dist/tools/sdk-utils/percy/types.d.ts +0 -5
  156. package/dist/tools/sdk-utils/types.d.ts +0 -40
  157. /package/dist/tools/{sdk-utils/percy → percy-snapshot-utils}/types.js +0 -0
@@ -0,0 +1,338 @@
1
+ import { PERCY_SNAPSHOT_INSTRUCTION } from "../common/constants.js";
2
+ export const percyAutomateReviewSnapshotsStep = `
3
+ ---STEP---
4
+ Review the snapshots
5
+ - Go to your Percy project on https://percy.io to review snapshots and approve/reject any visual changes.
6
+ `;
7
+ export const pythonPytestSeleniumInstructions = `
8
+ Install Percy Automate dependencies
9
+ - Install Percy CLI:
10
+ npm install --save-dev @percy/cli
11
+ - Install Percy Python SDK for Automate:
12
+ pip install percy-selenium
13
+
14
+ ---STEP---
15
+ Update your Pytest test script
16
+ ${PERCY_SNAPSHOT_INSTRUCTION}
17
+ - Import the Percy snapshot helper:
18
+ from percy import percy_screenshot
19
+ - In your test, take snapshots at key points:
20
+ percy_screenshot(driver, "Your snapshot name")
21
+
22
+ Example:
23
+ \`\`\`python
24
+ import pytest
25
+ from selenium import webdriver
26
+ from percy import percy_screenshot
27
+
28
+ @pytest.fixture
29
+ def driver():
30
+ driver = webdriver.Chrome()
31
+ yield driver
32
+ driver.quit()
33
+
34
+ def test_homepage(driver):
35
+ driver.get("http://localhost:8000")
36
+ percy_screenshot(driver, "Home page")
37
+ # ... more test steps ...
38
+ percy_screenshot(driver, "After login")
39
+ \`\`\`
40
+
41
+ ---STEP---
42
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- browserstack-sdk pytest').
43
+ ${percyAutomateReviewSnapshotsStep}
44
+ `;
45
+ export const pythonPytestPlaywrightInstructions = `
46
+ Install Percy Automate dependencies
47
+ - Install Percy CLI:
48
+ npm install --save @percy/cli
49
+ - Install Percy Playwright SDK for Automate:
50
+ pip install percy-playwright
51
+
52
+ ---STEP---
53
+ Update your Playwright test script
54
+ ${PERCY_SNAPSHOT_INSTRUCTION}
55
+ - Import the Percy screenshot helper:
56
+ from percy import percy_screenshot
57
+ - In your test, take snapshots at key points:
58
+ percy_screenshot(page, name="Your snapshot name")
59
+ # You can pass \`options\`:
60
+ percy_screenshot(page, name="Your snapshot name", options={ "full_page": True })
61
+
62
+ Example:
63
+ \`\`\`python
64
+ from playwright.sync_api import sync_playwright
65
+ from percy import percy_screenshot
66
+
67
+ def test_visual_regression():
68
+ with sync_playwright() as p:
69
+ browser = p.chromium.launch()
70
+ page = browser.new_page()
71
+ page.goto("http://localhost:8000")
72
+ percy_screenshot(page, name="Home page")
73
+ # ... more test steps ...
74
+ percy_screenshot(page, name="After login", options={ "full_page": True })
75
+ browser.close()
76
+ \`\`\`
77
+
78
+ ---STEP---
79
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- <command to run the script file>').
80
+ ${percyAutomateReviewSnapshotsStep}
81
+ `;
82
+ export const jsCypressPercyAutomateInstructions = `
83
+ Install Percy Automate dependencies
84
+ - Install Percy CLI:
85
+ npm install --save-dev @percy/cli
86
+ - Install Percy Cypress SDK:
87
+ npm install --save-dev @percy/cypress
88
+
89
+ ---STEP---
90
+ Update your Cypress test script
91
+ ${PERCY_SNAPSHOT_INSTRUCTION}
92
+ - Import and initialize Percy in your cypress/support/index.js:
93
+ import '@percy/cypress';
94
+ - In your test, take snapshots at key points:
95
+ cy.percySnapshot('Your snapshot name');
96
+
97
+ Example:
98
+ \`\`\`javascript
99
+ describe('Percy Automate Cypress Example', () => {
100
+ it('should take Percy snapshots', () => {
101
+ cy.visit('http://localhost:8000');
102
+ cy.percySnapshot('Home page');
103
+ // ... more test steps ...
104
+ cy.percySnapshot('After login');
105
+ });
106
+ });
107
+ \`\`\`
108
+
109
+ ---STEP---
110
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- cypress run').
111
+ ${percyAutomateReviewSnapshotsStep}
112
+ `;
113
+ export const mochaPercyAutomateInstructions = `
114
+ Install Percy Automate dependencies
115
+ - Install Percy CLI:
116
+ npm install --save @percy/cli
117
+ - Install Percy Selenium SDK:
118
+ npm install @percy/selenium-webdriver@2.0.1
119
+
120
+ ---STEP---
121
+ Update your Mocha Automate test script
122
+ - Import the Percy screenshot helper:
123
+ const { percyScreenshot } = require('@percy/selenium-webdriver');
124
+ - Use the Percy screenshot command to take required screenshots in your Automate session:
125
+ await percyScreenshot(driver, 'Screenshot 1');
126
+ options = { percyCSS: 'h1{color:red;}' };
127
+ await percyScreenshot(driver, 'Screenshot 2', options);
128
+
129
+ ---STEP---
130
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- mocha').
131
+ ${percyAutomateReviewSnapshotsStep}
132
+ `;
133
+ // Mocha Percy Playwright Instructions
134
+ export const mochaPercyPlaywrightInstructions = `
135
+ Install Percy Automate dependencies
136
+ - Install the latest Percy CLI:
137
+ npm install --save @percy/cli
138
+ - Install the Percy Playwright SDK:
139
+ npm install @percy/playwright
140
+
141
+ ---STEP---
142
+ Update your Mocha Playwright test script
143
+ - Import the Percy screenshot helper:
144
+ const { percyScreenshot } = require("@percy/playwright");
145
+ - Use the Percy screenshot command to take required screenshots in your Automate session.
146
+
147
+ Example:
148
+ \`\`\`javascript
149
+ const { percyScreenshot } = require("@percy/playwright");
150
+ await percyScreenshot(page, "Screenshot 1");
151
+ // With options
152
+ await percyScreenshot(page, "Screenshot 2", { percyCSS: "h1{color:green;}" });
153
+ \`\`\`
154
+
155
+ ---STEP---
156
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- <command to run the tests>').
157
+ ${percyAutomateReviewSnapshotsStep}
158
+ `;
159
+ export const jestPercyAutomateInstructions = `
160
+ Install or upgrade the BrowserStack SDK:
161
+ - Install the SDK:
162
+ npm i -D browserstack-node-sdk@latest
163
+ - Run the setup:
164
+ npx setup --username "YOUR_USERNAME" --key "YOUR_ACCESS_KEY"
165
+
166
+ ---STEP---
167
+ Manually capture screenshots:
168
+ 1. Import the BrowserStack Percy SDK in your test script:
169
+ const { percy } = require('browserstack-node-sdk');
170
+ 2. Use \`percy.screenshot(driver, name)\` at desired points in your test.
171
+
172
+ Example:
173
+ \`\`\`javascript
174
+ const { percy } = require('browserstack-node-sdk');
175
+ describe("JestJS test", () => {
176
+ let driver;
177
+ const caps = require("../" + conf_file).capabilities;
178
+
179
+ beforeAll(() => {
180
+ driver = new Builder()
181
+ .usingServer("http://example-servername/hub")
182
+ .withCapabilities(caps)
183
+ .build();
184
+ });
185
+
186
+ test("my test", async () => {
187
+ // ...
188
+ await percy.screenshot(driver, "My Screenshot");
189
+ // ...
190
+ });
191
+ });
192
+ \`\`\`
193
+
194
+ ---STEP---
195
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npm run [your-test-script-name]-browserstack').
196
+ ${percyAutomateReviewSnapshotsStep}
197
+ `;
198
+ export const webdriverioPercyAutomateInstructions = `
199
+ Install or upgrade BrowserStack SDK
200
+ - Install the BrowserStack SDK:
201
+ npm i -D @wdio/browserstack-service
202
+
203
+ ---STEP---
204
+ Update your WebdriverIO config file
205
+ 1. Set \`percy: true\`
206
+ 2. Set a \`projectName\`
207
+ 3. Set \`percyCaptureMode: auto\` (or another mode as needed)
208
+
209
+ Example WebdriverIO config:
210
+ \`\`\`js
211
+ exports.config = {
212
+ user: process.env.BROWSERSTACK_USERNAME || 'YOUR_USERNAME',
213
+ key: process.env.BROWSERSTACK_ACCESS_KEY || 'YOUR_ACCESS_KEY',
214
+ hostname: 'hub.browserstack.com',
215
+ services: [
216
+ [
217
+ 'browserstack',
218
+ { browserstackLocal: true, opts: { forcelocal: false }, percy: true, percyCaptureMode: 'auto' }
219
+ ],
220
+ ],
221
+ // add path to the test file
222
+ }
223
+ \`\`\`
224
+
225
+ ---STEP---
226
+ (Optional) Manually capture screenshots
227
+ 1. Import the BrowserStack Percy SDK in your test script:
228
+ const { percy } = require('browserstack-node-sdk');
229
+ 2. Add the \`await percy.screenshot(driver, name)\` method at required points in your test script.
230
+
231
+ Example:
232
+ \`\`\`javascript
233
+ const { percy } = require('browserstack-node-sdk');
234
+ 2. Add the \`await percy.screenshot(driver, name)\` method at required points in your test script.
235
+
236
+ Example:
237
+ \`\`\`javascript
238
+ const { percy } = require('browserstack-node-sdk');
239
+ describe("WebdriverIO Test", () => {
240
+ it("my test", async () => {
241
+ // ....
242
+ await percy.screenshot(driver, "My Screenshot")
243
+ // ....
244
+ });
245
+ });
246
+ \`\`\`
247
+
248
+ ---STEP---
249
+ To run the Percy build, call the tool runPercyScan with the appropriate test command as defined in your package.json file.
250
+ ${percyAutomateReviewSnapshotsStep}
251
+ `;
252
+ export const testcafePercyAutomateInstructions = `
253
+ Install Percy dependencies
254
+ - Install the required dependencies:
255
+ npm install --save-dev @percy/cli @percy/testcafe
256
+
257
+ ---STEP---
258
+ Update your test script
259
+ ${PERCY_SNAPSHOT_INSTRUCTION}
260
+ - Import the Percy library and use the percySnapshot function to take screenshots.
261
+
262
+ Example:
263
+ \`\`\`javascript
264
+ import percySnapshot from '@percy/testcafe';
265
+ fixture('MyFixture')
266
+ .page('https://devexpress.github.io/testcafe/example/');
267
+ test('Test1', async t => {
268
+ await t.typeText('#developer-name', 'John Doe');
269
+ await percySnapshot(t, 'TestCafe Example');
270
+ });
271
+ \`\`\`
272
+
273
+ ---STEP---
274
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- testcafe chrome:headless tests').
275
+ ${percyAutomateReviewSnapshotsStep}
276
+ `;
277
+ // Java Playwright Percy Automate Instructions
278
+ export const javaPlaywrightJunitInstructions = `
279
+ Install Percy Automate dependencies
280
+ - Install the latest Percy CLI:
281
+ npm install --save @percy/cli
282
+ - Add the Percy Playwright Java SDK to your pom.xml:
283
+ \`\`\`xml
284
+ <dependency>
285
+ <groupId>io.percy</groupId>
286
+ <artifactId>percy-playwright-java</artifactId>
287
+ <version>1.0.0</version>
288
+ </dependency>
289
+ \`\`\`
290
+
291
+ ---STEP---
292
+ Update your Automate test script
293
+ - Import the Percy library:
294
+ import io.percy.playwright.Percy;
295
+ - Use the Percy screenshot command to take required screenshots in your Automate session.
296
+
297
+ Example:
298
+ \`\`\`java
299
+ Percy percy = new Percy(page);
300
+ percy.screenshot("screenshot_1");
301
+ // With options
302
+ percy.screenshot("screenshot_2", options);
303
+ \`\`\`
304
+
305
+ ---STEP---
306
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- <command to run the automate script file>').
307
+
308
+ ${percyAutomateReviewSnapshotsStep}
309
+ `;
310
+ // C# Playwright NUnit Percy Automate Instructions
311
+ export const csharpPlaywrightNunitInstructions = `
312
+ Install Percy Automate dependencies
313
+ - Install the latest Percy CLI:
314
+ npm install --save @percy/cli
315
+ - Add the Percy Playwright SDK to your .csproj file:
316
+ \`\`\`xml
317
+ <PackageReference Include="PercyIO.Playwright" Version="1.0.0" />
318
+ \`\`\`
319
+
320
+ ---STEP---
321
+ Update your NUnit Playwright test script
322
+ - Import the Percy library:
323
+ using PercyIO.Playwright;
324
+ - Use the Percy screenshot command to take required screenshots in your Automate session.
325
+
326
+ Example:
327
+ \`\`\`csharp
328
+ using PercyIO.Playwright;
329
+ Percy.Screenshot(page, "example_screenshot_1");
330
+ // With options
331
+ Percy.Screenshot(page, "example_screenshot_2", options);
332
+ \`\`\`
333
+
334
+ ---STEP---
335
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- <command to run the automate script file>').
336
+
337
+ ${percyAutomateReviewSnapshotsStep}
338
+ `;
@@ -0,0 +1,8 @@
1
+ import { ConfigMapping } from "./types.js";
2
+ export declare const SUPPORTED_CONFIGURATIONS: ConfigMapping;
3
+ /**
4
+ * Utility function to check if a given language, driver, and testing framework
5
+ * are supported by Percy Automate.
6
+ * This now expects the structure: language -> driver -> framework
7
+ */
8
+ export declare function isPercyAutomateFrameworkSupported(language: string, driver: string, framework: string): boolean;
@@ -0,0 +1,50 @@
1
+ import * as instructions from "./constants.js";
2
+ export const SUPPORTED_CONFIGURATIONS = {
3
+ python: {
4
+ selenium: {
5
+ pytest: {
6
+ instructions: instructions.pythonPytestSeleniumInstructions,
7
+ },
8
+ },
9
+ playwright: {
10
+ pytest: {
11
+ instructions: instructions.pythonPytestPlaywrightInstructions,
12
+ },
13
+ },
14
+ },
15
+ java: {
16
+ playwright: {
17
+ junit: { instructions: instructions.javaPlaywrightJunitInstructions },
18
+ },
19
+ },
20
+ nodejs: {
21
+ selenium: {
22
+ mocha: { instructions: instructions.mochaPercyAutomateInstructions },
23
+ jest: { instructions: instructions.jestPercyAutomateInstructions },
24
+ webdriverio: {
25
+ instructions: instructions.webdriverioPercyAutomateInstructions,
26
+ },
27
+ testcafe: {
28
+ instructions: instructions.testcafePercyAutomateInstructions,
29
+ },
30
+ },
31
+ playwright: {
32
+ mocha: { instructions: instructions.mochaPercyPlaywrightInstructions },
33
+ jest: { instructions: instructions.jestPercyAutomateInstructions },
34
+ },
35
+ },
36
+ };
37
+ /**
38
+ * Utility function to check if a given language, driver, and testing framework
39
+ * are supported by Percy Automate.
40
+ * This now expects the structure: language -> driver -> framework
41
+ */
42
+ export function isPercyAutomateFrameworkSupported(language, driver, framework) {
43
+ const languageConfig = SUPPORTED_CONFIGURATIONS[language];
44
+ if (!languageConfig)
45
+ return false;
46
+ const driverConfig = languageConfig[driver];
47
+ if (!driverConfig)
48
+ return false;
49
+ return !!driverConfig[framework];
50
+ }
@@ -0,0 +1,3 @@
1
+ import { RunTestsInstructionResult } from "../common/types.js";
2
+ import { SetUpPercyInput } from "../common/schema.js";
3
+ export declare function runPercyAutomateOnly(input: SetUpPercyInput, percyToken: string): RunTestsInstructionResult;
@@ -0,0 +1,30 @@
1
+ import { SUPPORTED_CONFIGURATIONS } from "./frameworks.js";
2
+ export function runPercyAutomateOnly(input, percyToken) {
3
+ const steps = [];
4
+ // Assume configuration is supported due to guardrails at orchestration layer
5
+ const languageConfig = SUPPORTED_CONFIGURATIONS[input.detectedLanguage];
6
+ const driverConfig = languageConfig[input.detectedBrowserAutomationFramework];
7
+ const testingFrameworkConfig = driverConfig
8
+ ? driverConfig[input.detectedTestingFramework]
9
+ : undefined;
10
+ // Generate instructions for the supported configuration with project name
11
+ const instructions = testingFrameworkConfig
12
+ ? testingFrameworkConfig.instructions
13
+ : "";
14
+ // Prepend a step to set the Percy token in the environment
15
+ steps.push({
16
+ type: "instruction",
17
+ title: "Set Percy Token in Environment",
18
+ content: `Here is percy token if required {${percyToken}}`,
19
+ });
20
+ steps.push({
21
+ type: "instruction",
22
+ title: `Percy Automate Setup for ${input.detectedLanguage} with ${input.detectedTestingFramework}`,
23
+ content: instructions,
24
+ });
25
+ return {
26
+ steps,
27
+ requiresPercy: true,
28
+ missingDependencies: [],
29
+ };
30
+ }
@@ -0,0 +1 @@
1
+ export { runPercyAutomateOnly } from "./handler.js";
@@ -0,0 +1,2 @@
1
+ // Percy Automate utilities
2
+ export { runPercyAutomateOnly } from "./handler.js";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Type for Percy Automate configuration mapping.
3
+ * Structure: language -> driver -> testingFramework -> { instructions: string }
4
+ */
5
+ export type ConfigMapping = {
6
+ [language: string]: {
7
+ [driver: string]: {
8
+ [framework: string]: {
9
+ instructions: string;
10
+ };
11
+ };
12
+ };
13
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare const javaSeleniumInstructions = "\nImport the BrowserStack Percy SDK in your test script:\nAdd the Percy import to your test file.\n\n\nInvoke listTestFiles() with the provided directories from user to gather all test files in memory and obtain the generated UUID ---STEP---\nProcess files in STRICT sequential order using tool addPercySnapshotCommands() with below instructions:\n- Start with index 0\n- Then index 1 \n- Then index 2\n- Continue sequentially until the last index\n- DO NOT skip any index numbers\n- DO NOT jump to random indices like 10, 20, 30\n- DO NOT worry about time consuming and any constraints.\n- DO NOT STOP until you add commands in all the files or you reach end of the files.\n\n\nAdd screenshot capture method at required points:\nUse the `PercySDK.screenshot(driver, name)` method at points in your test script where you want to capture screenshots.\n\nHere's an example:\n\n```java\n// ...imports\nimport com.browserstack.PercySDK;\n\npublic class YourTestClass extends YourBaseTest {\n @Test\n public void test() throws Exception {\n // your test logic\n // ...\n \n // Capture a Percy screenshot\n PercySDK.screenshot(driver, \"My Screenshot Name\");\n \n // ...\n // more test logic\n }\n}\n```\n";
2
+ export declare const nodejsSeleniumInstructions = "\nImport the BrowserStack Percy SDK in your test script:\nAdd the Percy import to your test file.\n\n\nInvoke listTestFiles() with the provided directories from user to gather all test files in memory and obtain the generated UUID ---STEP---\nProcess files in STRICT sequential order using tool addPercySnapshotCommands() with below instructions:\n- Start with index 0\n- Then index 1 \n- Then index 2\n- Continue sequentially until the last index\n- DO NOT skip any index numbers\n- DO NOT jump to random indices like 10, 20, 30\n- DO NOT worry about time consuming and any constraints.\n- DO NOT STOP until you add commands in all the files or you reach end of the files.\n\n\n---STEP---\n\nAdd screenshot capture method at required points:\nUse the `percy.snapshot(driver, name)` method at points in your test script where you want to capture screenshots.\n\n```javascript\nconst { percy } = require('browserstack-node-sdk');\ndescribe(\"sample Test\", () => {\n // ... other imports and setup\n \n test(\"my test\", async () => {\n // ....\n await percy.screenshot(driver, \"My Snapshot\")\n // ....\n });\n})\n```\n";
3
+ export declare const webdriverioPercyInstructions = "\nEnable Percy in `wdio.conf.js`:\nIn your WebdriverIO configuration file, modify the 'browserstack' service options to enable Percy.\n\n- Set `percy: true`.\n- Set a `projectName`. This is required and will be used for both your Automate and Percy projects.\n- Set `percyCaptureMode`. The default `manual` as we are adding screenshot commands manually.\n\nHere's how to modify the service configuration:\n```javascript\n// in wdio.conf.js\n\nexports.config = {\n // ... other configs\n services: [\n [\n 'browserstack',\n { \n // ... other service options\n percy: true,\n percyCaptureMode: 'manual' // or 'auto', etc.\n },\n ],\n ],\n\n commonCapabilities: {\n 'bstack:options': {\n projectName: \"My Percy Project\", // This is required for Percy\n // ... other common capabilities\n }\n },\n // ... rest of your config\n};\n```\n\n\nInvoke listTestFiles() with the provided directories from user to gather all test files in memory and obtain the generated UUID ---STEP---\nProcess files in STRICT sequential order using tool addPercySnapshotCommands() with below instructions:\n- Start with index 0\n- Then index 1 \n- Then index 2\n- Continue sequentially until the last index\n- DO NOT skip any index numbers\n- DO NOT jump to random indices like 10, 20, 30\n- DO NOT worry about time consuming and any constraints.\n- DO NOT STOP until you add commands in all the files or you reach end of the files.\n\n\n---STEP---\n\nManually Capturing Screenshots (Optional):\nIf you set `percyCaptureMode: 'manual'` or want to take extra screenshots in `auto` mode, you need to add screenshot commands to your tests.\n\nFirst, install `browserstack-node-sdk`:\n```bash\nnpm install browserstack-node-sdk\n```\n\nThen, in your test script, import `percy` and use it to take a snapshot:\n```javascript\n// your_test_file.js\nconst { percy } = require('browserstack-node-sdk');\n\ndescribe(\"My WebdriverIO Test\", () => {\n it(\"should take a percy snapshot\", async () => {\n // ... your test logic (e.g., browser.url('https://example.com'))\n \n // Capture a Percy screenshot\n await percy.screenshot(driver, \"My Snapshot Name\");\n \n // ... more test logic\n });\n});\n```\n";
4
+ export declare const csharpSeleniumInstructions = "\nImport the BrowserStack Percy SDK in your test script:\nAdd the Percy import to your test file.\n\n\nInvoke listTestFiles() with the provided directories from user to gather all test files in memory and obtain the generated UUID ---STEP---\nProcess files in STRICT sequential order using tool addPercySnapshotCommands() with below instructions:\n- Start with index 0\n- Then index 1 \n- Then index 2\n- Continue sequentially until the last index\n- DO NOT skip any index numbers\n- DO NOT jump to random indices like 10, 20, 30\n- DO NOT worry about time consuming and any constraints.\n- DO NOT STOP until you add commands in all the files or you reach end of the files.\n\n\nAdd screenshot capture method at required points:\nUse the `PercySDK.Screenshot(driver, name)` method at points in your test script where you want to capture screenshots.\n\nHere's an example:\n\n```csharp\nusing BrowserStackSDK.Percy;\nnamespace Tests;\n\npublic class MyTest\n{\n [Test]\n public void SampleTest()\n {\n // your test logic\n // ...\n \n // Capture a Percy screenshot\n PercySDK.Screenshot(driver, \"Screenshot name\");\n \n // ...\n // more test logic\n }\n}\n```\n";
@@ -1,8 +1,9 @@
1
- const javaSeleniumInstructions = `
1
+ import { PERCY_SNAPSHOT_INSTRUCTION } from "../common/constants.js";
2
+ export const javaSeleniumInstructions = `
2
3
  Import the BrowserStack Percy SDK in your test script:
3
4
  Add the Percy import to your test file.
4
5
 
5
- ---STEP---
6
+ ${PERCY_SNAPSHOT_INSTRUCTION}
6
7
 
7
8
  Add screenshot capture method at required points:
8
9
  Use the \`PercySDK.screenshot(driver, name)\` method at points in your test script where you want to capture screenshots.
@@ -32,6 +33,8 @@ export const nodejsSeleniumInstructions = `
32
33
  Import the BrowserStack Percy SDK in your test script:
33
34
  Add the Percy import to your test file.
34
35
 
36
+ ${PERCY_SNAPSHOT_INSTRUCTION}
37
+
35
38
  ---STEP---
36
39
 
37
40
  Add screenshot capture method at required points:
@@ -44,19 +47,19 @@ describe("sample Test", () => {
44
47
 
45
48
  test("my test", async () => {
46
49
  // ....
47
- await percy.snapshot(driver, "My Snapshot")
50
+ await percy.screenshot(driver, "My Snapshot")
48
51
  // ....
49
52
  });
50
53
  })
51
54
  \`\`\`
52
55
  `;
53
- const webdriverioPercyInstructions = `
56
+ export const webdriverioPercyInstructions = `
54
57
  Enable Percy in \`wdio.conf.js\`:
55
58
  In your WebdriverIO configuration file, modify the 'browserstack' service options to enable Percy.
56
59
 
57
60
  - Set \`percy: true\`.
58
61
  - Set a \`projectName\`. This is required and will be used for both your Automate and Percy projects.
59
- - Set \`percyCaptureMode\`. The default \`auto\` mode is recommended, which captures screenshots on events like clicks. Other modes are \`testcase\`, \`click\`, \`screenshot\`, and \`manual\`.
62
+ - Set \`percyCaptureMode\`. The default \`manual\` as we are adding screenshot commands manually.
60
63
 
61
64
  Here's how to modify the service configuration:
62
65
  \`\`\`javascript
@@ -70,7 +73,7 @@ exports.config = {
70
73
  {
71
74
  // ... other service options
72
75
  percy: true,
73
- percyCaptureMode: 'auto' // or 'manual', 'testcase', etc.
76
+ percyCaptureMode: 'manual' // or 'auto', etc.
74
77
  },
75
78
  ],
76
79
  ],
@@ -85,6 +88,8 @@ exports.config = {
85
88
  };
86
89
  \`\`\`
87
90
 
91
+ ${PERCY_SNAPSHOT_INSTRUCTION}
92
+
88
93
  ---STEP---
89
94
 
90
95
  Manually Capturing Screenshots (Optional):
@@ -112,11 +117,11 @@ describe("My WebdriverIO Test", () => {
112
117
  });
113
118
  \`\`\`
114
119
  `;
115
- const csharpSeleniumInstructions = `
120
+ export const csharpSeleniumInstructions = `
116
121
  Import the BrowserStack Percy SDK in your test script:
117
122
  Add the Percy import to your test file.
118
123
 
119
- ---STEP---
124
+ ${PERCY_SNAPSHOT_INSTRUCTION}
120
125
 
121
126
  Add screenshot capture method at required points:
122
127
  Use the \`PercySDK.Screenshot(driver, name)\` method at points in your test script where you want to capture screenshots.
@@ -125,8 +130,6 @@ Here's an example:
125
130
 
126
131
  \`\`\`csharp
127
132
  using BrowserStackSDK.Percy;
128
- using NUnit.Framework;
129
-
130
133
  namespace Tests;
131
134
 
132
135
  public class MyTest
@@ -146,32 +149,3 @@ public class MyTest
146
149
  }
147
150
  \`\`\`
148
151
  `;
149
- export const PERCY_INSTRUCTIONS = {
150
- java: {
151
- selenium: {
152
- testng: { script_updates: javaSeleniumInstructions },
153
- cucumber: { script_updates: javaSeleniumInstructions },
154
- junit4: { script_updates: javaSeleniumInstructions },
155
- junit5: { script_updates: javaSeleniumInstructions },
156
- serenity: { script_updates: javaSeleniumInstructions },
157
- },
158
- },
159
- csharp: {
160
- selenium: {
161
- nunit: { script_updates: csharpSeleniumInstructions },
162
- },
163
- },
164
- nodejs: {
165
- selenium: {
166
- mocha: {
167
- script_updates: nodejsSeleniumInstructions,
168
- },
169
- jest: {
170
- script_updates: nodejsSeleniumInstructions,
171
- },
172
- webdriverio: {
173
- script_updates: webdriverioPercyInstructions,
174
- },
175
- },
176
- },
177
- };
@@ -0,0 +1,2 @@
1
+ import { ConfigMapping } from "./types.js";
2
+ export declare const PERCY_INSTRUCTIONS: ConfigMapping;
@@ -0,0 +1,27 @@
1
+ import * as constants from "./constants.js";
2
+ export const PERCY_INSTRUCTIONS = {
3
+ java: {
4
+ selenium: {
5
+ testng: { instructions: constants.javaSeleniumInstructions },
6
+ cucumber: { instructions: constants.javaSeleniumInstructions },
7
+ junit4: { instructions: constants.javaSeleniumInstructions },
8
+ junit5: { instructions: constants.javaSeleniumInstructions },
9
+ selenide: { instructions: constants.javaSeleniumInstructions },
10
+ jbehave: { instructions: constants.javaSeleniumInstructions },
11
+ },
12
+ },
13
+ csharp: {
14
+ selenium: {
15
+ nunit: { instructions: constants.csharpSeleniumInstructions },
16
+ xunit: { instructions: constants.csharpSeleniumInstructions },
17
+ specflow: { instructions: constants.csharpSeleniumInstructions },
18
+ },
19
+ },
20
+ nodejs: {
21
+ selenium: {
22
+ mocha: { instructions: constants.nodejsSeleniumInstructions },
23
+ jest: { instructions: constants.nodejsSeleniumInstructions },
24
+ webdriverio: { instructions: constants.webdriverioPercyInstructions },
25
+ },
26
+ },
27
+ };
@@ -0,0 +1,4 @@
1
+ import { RunTestsInstructionResult } from "../common/types.js";
2
+ import { RunTestsOnBrowserStackInput } from "../common/schema.js";
3
+ import { BrowserStackConfig } from "../../../lib/types.js";
4
+ export declare function runPercyWithBrowserstackSDK(input: RunTestsOnBrowserStackInput, config: BrowserStackConfig): RunTestsInstructionResult;