@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
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * ---------- PYTHON INSTRUCTIONS ----------
3
3
  */
4
- const pythonInstructions = (username, accessKey) => `
4
+ export const pythonInstructions = (username, accessKey) => {
5
+ const setup = `
5
6
  ---STEP---
6
7
 
7
8
  Install the BrowserStack SDK:
@@ -15,7 +16,8 @@ Setup the BrowserStack SDK with your credentials:
15
16
  \`\`\`bash
16
17
  browserstack-sdk setup --username "${username}" --key "${accessKey}"
17
18
  \`\`\`
18
-
19
+ `;
20
+ const run = `
19
21
  ---STEP---
20
22
 
21
23
  Run your tests on BrowserStack:
@@ -23,7 +25,10 @@ Run your tests on BrowserStack:
23
25
  browserstack-sdk python <path-to-test-file>
24
26
  \`\`\`
25
27
  `;
26
- const generatePythonFrameworkInstructions = (framework) => (username, accessKey) => `
28
+ return { setup, run };
29
+ };
30
+ export const generatePythonFrameworkInstructions = (framework) => (username, accessKey) => {
31
+ const setup = `
27
32
  ---STEP---
28
33
 
29
34
  Install the BrowserStack SDK:
@@ -38,7 +43,8 @@ Setup the BrowserStack SDK with framework-specific configuration:
38
43
  \`\`\`bash
39
44
  browserstack-sdk setup --framework "${framework}" --username "${username}" --key "${accessKey}"
40
45
  \`\`\`
41
-
46
+ `;
47
+ const run = `
42
48
  ---STEP---
43
49
 
44
50
  Run your ${framework} tests on BrowserStack:
@@ -46,14 +52,17 @@ Run your ${framework} tests on BrowserStack:
46
52
  browserstack-sdk ${framework} <path-to-test-files>
47
53
  \`\`\`
48
54
  `;
49
- const robotInstructions = generatePythonFrameworkInstructions("robot");
50
- const behaveInstructions = generatePythonFrameworkInstructions("behave");
51
- const pytestInstructions = generatePythonFrameworkInstructions("pytest");
55
+ return { setup, run };
56
+ };
57
+ export const robotInstructions = generatePythonFrameworkInstructions("robot");
58
+ export const behaveInstructions = generatePythonFrameworkInstructions("behave");
59
+ export const pytestInstructions = generatePythonFrameworkInstructions("pytest");
52
60
  /**
53
61
  * ---------- JAVA INSTRUCTIONS ----------
54
62
  */
55
63
  const argsInstruction = '<argLine>-javaagent:"${com.browserstack:browserstack-java-sdk:jar}"</argLine>';
56
- const javaInstructions = (username, accessKey) => `
64
+ export const javaInstructions = (username, accessKey) => {
65
+ const setup = `
57
66
  ---STEP---
58
67
 
59
68
  Add the BrowserStack Java SDK dependency to your \`pom.xml\`:
@@ -82,7 +91,8 @@ Export your BrowserStack credentials as environment variables:
82
91
  export BROWSERSTACK_USERNAME=${username}
83
92
  export BROWSERSTACK_ACCESS_KEY=${accessKey}
84
93
  \`\`\`
85
-
94
+ `;
95
+ const run = `
86
96
  ---STEP---
87
97
 
88
98
  Run your tests using Maven:
@@ -95,66 +105,13 @@ Or for Gradle:
95
105
  gradle clean test
96
106
  \`\`\`
97
107
  `;
98
- const serenityInstructions = (username, accessKey) => `
99
- ---STEP---
100
-
101
- Set BrowserStack credentials as environment variables:
102
- For macOS/Linux:
103
- \`\`\`bash
104
- export BROWSERSTACK_USERNAME=${username}
105
- export BROWSERSTACK_ACCESS_KEY=${accessKey}
106
- \`\`\`
107
-
108
- For Windows Command Prompt:
109
- \`\`\`cmd
110
- set BROWSERSTACK_USERNAME=${username}
111
- set BROWSERSTACK_ACCESS_KEY=${accessKey}
112
- \`\`\`
113
-
114
- ---STEP---
115
-
116
- Add serenity-browserstack dependency in pom.xml:
117
- Add the following dependency to your pom.xml file and save it:
118
- \`\`\`xml
119
- <dependency>
120
- <groupId>net.serenity-bdd</groupId>
121
- <artifactId>serenity-browserstack</artifactId>
122
- <version>3.3.4</version>
123
- </dependency>
124
- \`\`\`
125
-
126
- ---STEP---
127
-
128
- Set up serenity.conf file:
129
- Create or update your serenity.conf file in the project root with the following configuration:
130
- \`\`\`
131
- webdriver {
132
- driver = remote
133
- remote.url = "https://hub.browserstack.com/wd/hub"
134
- }
135
- browserstack.user="${username}"
136
- browserstack.key="${accessKey}"
137
- \`\`\`
138
-
139
- ---STEP---
140
-
141
- Run your Serenity tests:
142
- You can continue running your tests as you normally would. For example:
143
-
144
- Using Maven:
145
- \`\`\`bash
146
- mvn clean verify
147
- \`\`\`
148
-
149
- Using Gradle:
150
- \`\`\`bash
151
- gradle clean test
152
- \`\`\`
153
- `;
108
+ return { setup, run };
109
+ };
154
110
  /**
155
111
  * ---------- CSharp INSTRUCTIONS ----------
156
112
  */
157
- const csharpCommonInstructions = (username, accessKey) => `
113
+ export const csharpCommonInstructions = (username, accessKey) => {
114
+ const setup = `
158
115
  ---STEP---
159
116
 
160
117
  Install BrowserStack TestAdapter NuGet package:
@@ -203,7 +160,8 @@ Install the x64 version of .NET for BrowserStack compatibility.
203
160
  sudo dotnet browserstack-sdk setup-dotnet --dotnet-path "<your-chosen-path>" --dotnet-version "<your-dotnet-version>"
204
161
  \`\`\`
205
162
  Common paths: /usr/local/share/dotnet, ~/dotnet-x64, or /opt/dotnet-x64
206
-
163
+ `;
164
+ const run = `
207
165
  ---STEP---
208
166
 
209
167
  Run the tests:
@@ -216,7 +174,10 @@ Run the tests:
216
174
  dotnet test
217
175
  \`\`\`
218
176
  `;
219
- const csharpPlaywrightCommonInstructions = (username, accessKey) => `
177
+ return { setup, run };
178
+ };
179
+ export const csharpPlaywrightCommonInstructions = (username, accessKey) => {
180
+ const setup = `
220
181
  ---STEP---
221
182
 
222
183
  Install BrowserStack TestAdapter NuGet package:
@@ -278,7 +239,8 @@ Fix for Playwright architecture (macOS only):
278
239
  If the folder exists:
279
240
  \`<project-folder>/bin/Debug/net8.0/.playwright/node/darwin-arm64\`
280
241
  Rename \`darwin-arm64\` to \`darwin-x64\`
281
-
242
+ `;
243
+ const run = `
282
244
  ---STEP---
283
245
 
284
246
  Run the tests:
@@ -291,10 +253,13 @@ Run the tests:
291
253
  dotnet test
292
254
  \`\`\`
293
255
  `;
256
+ return { setup, run };
257
+ };
294
258
  /**
295
259
  * ---------- NODEJS INSTRUCTIONS ----------
296
260
  */
297
- const nodejsInstructions = (username, accessKey) => `
261
+ export const nodejsInstructions = (username, accessKey) => {
262
+ const setup = `
298
263
  ---STEP---
299
264
 
300
265
  Ensure \`browserstack-node-sdk\` is present in package.json with the latest version:
@@ -330,10 +295,21 @@ export BROWSERSTACK_ACCESS_KEY=${accessKey}
330
295
  Run your tests:
331
296
  You can now run your tests on BrowserStack using your standard command or Use the commands defined in your package.json file to run the tests.
332
297
  `;
298
+ const run = `
299
+ ---STEP---
300
+
301
+ Run your tests on BrowserStack:
302
+ \`\`\`bash
303
+ npm run test:browserstack
304
+ \`\`\`
305
+ `;
306
+ return { setup, run };
307
+ };
333
308
  /**
334
309
  * ---------- EXPORT CONFIG ----------
335
310
  */
336
- const webdriverioInstructions = (username, accessKey) => `
311
+ export const webdriverioInstructions = (username, accessKey) => {
312
+ const setup = `
337
313
  ---STEP---
338
314
 
339
315
  Set BrowserStack Credentials:
@@ -432,13 +408,17 @@ exports.config.capabilities.forEach(function (caps) {
432
408
  caps[i] = { ...caps[i], ...exports.config.commonCapabilities[i]};
433
409
  });
434
410
  \`\`\`
435
-
411
+ `;
412
+ const run = `
436
413
  ---STEP---
437
414
 
438
415
  Run your tests:
439
416
  You can now run your tests on BrowserStack using your standard WebdriverIO command or Use the commands defined in your package.json file to run the tests.
440
417
  `;
441
- const cypressInstructions = (username, accessKey) => `
418
+ return { setup, run };
419
+ };
420
+ export const cypressInstructions = (username, accessKey) => {
421
+ const setup = `
442
422
  ---STEP---
443
423
 
444
424
  Install the BrowserStack Cypress CLI:
@@ -499,7 +479,8 @@ Open the generated \`browserstack.json\` file and update it with your BrowserSta
499
479
  \`\`\`
500
480
 
501
481
  **Note:** For Cypress v9 or lower, use \`"cypress_config_file": "./cypress.json"\`. The \`testObservability: true\` flag enables the [Test Reporting & Analytics dashboard](https://www.browserstack.com/docs/test-management/test-reporting-and-analytics) for deeper insights into your test runs.
502
-
482
+ `;
483
+ const run = `
503
484
  ---STEP---
504
485
 
505
486
  Run Your Tests on BrowserStack:
@@ -508,8 +489,69 @@ Execute your tests on BrowserStack using the following command:
508
489
  npx browserstack-cypress run --sync
509
490
  \`\`\`
510
491
 
511
- After the tests complete, you can view the results on your [BrowserStack Automate Dashboard](https://automate.browserstack.com/dashboard/).
492
+ After the tests complete, you can view the results on your [BrowserStack Automate Dashboard](https://automate.browserstack.com/dashboard/).`;
493
+ return { setup, run };
494
+ };
495
+ const serenityInstructions = (username, accessKey) => {
496
+ const setup = `
497
+ ---STEP---
498
+
499
+ Set BrowserStack credentials as environment variables:
500
+ For macOS/Linux:
501
+ \`\`\`bash
502
+ export BROWSERSTACK_USERNAME=${username}
503
+ export BROWSERSTACK_ACCESS_KEY=${accessKey}
504
+ \`\`\`
505
+
506
+ For Windows Command Prompt:
507
+ \`\`\`cmd
508
+ set BROWSERSTACK_USERNAME=${username}
509
+ set BROWSERSTACK_ACCESS_KEY=${accessKey}
510
+ \`\`\`
511
+
512
+ ---STEP---
513
+
514
+ Add serenity-browserstack dependency in pom.xml:
515
+ Add the following dependency to your pom.xml file and save it:
516
+ \`\`\`xml
517
+ <dependency>
518
+ <groupId>net.serenity-bdd</groupId>
519
+ <artifactId>serenity-browserstack</artifactId>
520
+ <version>3.3.4</version>
521
+ </dependency>
522
+ \`\`\`
523
+
524
+ ---STEP---
525
+
526
+ Set up serenity.conf file:
527
+ Create or update your serenity.conf file in the project root with the following configuration:
528
+ \`\`\`
529
+ webdriver {
530
+ driver = remote
531
+ remote.url = "https://hub.browserstack.com/wd/hub"
532
+ }
533
+ browserstack.user="${username}"
534
+ browserstack.key="${accessKey}"
535
+ \`\`\`
512
536
  `;
537
+ const run = `
538
+ ---STEP---
539
+
540
+ Run your Serenity tests:
541
+ You can continue running your tests as you normally would. For example:
542
+
543
+ Using Maven:
544
+ \`\`\`bash
545
+ mvn clean verify
546
+ \`\`\`
547
+
548
+ Using Gradle:
549
+ \`\`\`bash
550
+ gradle clean test
551
+ \`\`\`
552
+ `;
553
+ return { setup, run };
554
+ };
513
555
  export const SUPPORTED_CONFIGURATIONS = {
514
556
  python: {
515
557
  playwright: {
@@ -565,8 +607,5 @@ export const SUPPORTED_CONFIGURATIONS = {
565
607
  cypress: {
566
608
  cypress: { instructions: cypressInstructions },
567
609
  },
568
- webdriverio: {
569
- mocha: { instructions: webdriverioInstructions },
570
- },
571
610
  },
572
611
  };
@@ -1,2 +1,2 @@
1
- import { ConfigMapping } from "./types.js";
1
+ import { ConfigMapping } from "../common/types.js";
2
2
  export declare const SUPPORTED_CONFIGURATIONS: ConfigMapping;
@@ -0,0 +1,57 @@
1
+ import * as constants from "./constants.js";
2
+ export const SUPPORTED_CONFIGURATIONS = {
3
+ python: {
4
+ playwright: {
5
+ pytest: { instructions: constants.pythonInstructions },
6
+ },
7
+ selenium: {
8
+ pytest: { instructions: constants.pytestInstructions },
9
+ robot: { instructions: constants.robotInstructions },
10
+ behave: { instructions: constants.behaveInstructions },
11
+ },
12
+ },
13
+ java: {
14
+ playwright: {
15
+ junit4: { instructions: constants.javaInstructions },
16
+ junit5: { instructions: constants.javaInstructions },
17
+ testng: { instructions: constants.javaInstructions },
18
+ },
19
+ selenium: {
20
+ testng: { instructions: constants.javaInstructions },
21
+ cucumber: { instructions: constants.javaInstructions },
22
+ junit4: { instructions: constants.javaInstructions },
23
+ junit5: { instructions: constants.javaInstructions },
24
+ },
25
+ },
26
+ csharp: {
27
+ playwright: {
28
+ nunit: { instructions: constants.csharpPlaywrightCommonInstructions },
29
+ mstest: { instructions: constants.csharpPlaywrightCommonInstructions },
30
+ },
31
+ selenium: {
32
+ xunit: { instructions: constants.csharpCommonInstructions },
33
+ nunit: { instructions: constants.csharpCommonInstructions },
34
+ mstest: { instructions: constants.csharpCommonInstructions },
35
+ specflow: { instructions: constants.csharpCommonInstructions },
36
+ reqnroll: { instructions: constants.csharpCommonInstructions },
37
+ },
38
+ },
39
+ nodejs: {
40
+ playwright: {
41
+ jest: { instructions: constants.nodejsInstructions },
42
+ codeceptjs: { instructions: constants.nodejsInstructions },
43
+ playwright: { instructions: constants.nodejsInstructions },
44
+ },
45
+ selenium: {
46
+ jest: { instructions: constants.nodejsInstructions },
47
+ webdriverio: { instructions: constants.webdriverioInstructions },
48
+ mocha: { instructions: constants.nodejsInstructions },
49
+ cucumber: { instructions: constants.nodejsInstructions },
50
+ nightwatch: { instructions: constants.nodejsInstructions },
51
+ codeceptjs: { instructions: constants.nodejsInstructions },
52
+ },
53
+ cypress: {
54
+ cypress: { instructions: constants.cypressInstructions },
55
+ },
56
+ },
57
+ };
@@ -0,0 +1,4 @@
1
+ export { runBstackSDKOnly } from "./sdkHandler.js";
2
+ export { getSDKPrefixCommand, getJavaFrameworkForMaven } from "./commands.js";
3
+ export { generateBrowserStackYMLInstructions } from "./configUtils.js";
4
+ export { SUPPORTED_CONFIGURATIONS } from "./frameworks.js";
@@ -0,0 +1,5 @@
1
+ // BrowserStack SDK utilities
2
+ export { runBstackSDKOnly } from "./sdkHandler.js";
3
+ export { getSDKPrefixCommand, getJavaFrameworkForMaven } from "./commands.js";
4
+ export { generateBrowserStackYMLInstructions } from "./configUtils.js";
5
+ export { SUPPORTED_CONFIGURATIONS } from "./frameworks.js";
@@ -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 runBstackSDKOnly(input: RunTestsOnBrowserStackInput, config: BrowserStackConfig, isPercyAutomate?: boolean): RunTestsInstructionResult;
@@ -0,0 +1,74 @@
1
+ import { getBrowserStackAuth } from "../../../lib/get-auth.js";
2
+ import { getSDKPrefixCommand } from "./commands.js";
3
+ import { generateBrowserStackYMLInstructions } from "./configUtils.js";
4
+ import { getInstructionsForProjectConfiguration } from "../common/instructionUtils.js";
5
+ export function runBstackSDKOnly(input, config, isPercyAutomate = false) {
6
+ const steps = [];
7
+ const authString = getBrowserStackAuth(config);
8
+ const [username, accessKey] = authString.split(":");
9
+ // Handle frameworks with unique setup instructions that don't use browserstack.yml
10
+ if (input.detectedBrowserAutomationFramework === "cypress" ||
11
+ input.detectedTestingFramework === "webdriverio") {
12
+ const frameworkInstructions = getInstructionsForProjectConfiguration(input.detectedBrowserAutomationFramework, input.detectedTestingFramework, input.detectedLanguage, username, accessKey);
13
+ if (frameworkInstructions) {
14
+ if (frameworkInstructions.setup) {
15
+ steps.push({
16
+ type: "instruction",
17
+ title: "Framework-Specific Setup",
18
+ content: frameworkInstructions.setup,
19
+ });
20
+ }
21
+ if (frameworkInstructions.run && !isPercyAutomate) {
22
+ steps.push({
23
+ type: "instruction",
24
+ title: "Run the tests",
25
+ content: frameworkInstructions.run,
26
+ });
27
+ }
28
+ }
29
+ return {
30
+ steps,
31
+ requiresPercy: false,
32
+ missingDependencies: [],
33
+ };
34
+ }
35
+ // Default flow using browserstack.yml
36
+ const sdkSetupCommand = getSDKPrefixCommand(input.detectedLanguage, input.detectedTestingFramework, username, accessKey);
37
+ if (sdkSetupCommand) {
38
+ steps.push({
39
+ type: "instruction",
40
+ title: "Install BrowserStack SDK",
41
+ content: sdkSetupCommand,
42
+ });
43
+ }
44
+ const ymlInstructions = generateBrowserStackYMLInstructions(input.desiredPlatforms, false, input.projectName);
45
+ if (ymlInstructions) {
46
+ steps.push({
47
+ type: "instruction",
48
+ title: "Configure browserstack.yml",
49
+ content: ymlInstructions,
50
+ });
51
+ }
52
+ const frameworkInstructions = getInstructionsForProjectConfiguration(input.detectedBrowserAutomationFramework, input.detectedTestingFramework, input.detectedLanguage, username, accessKey);
53
+ if (frameworkInstructions) {
54
+ if (frameworkInstructions.setup) {
55
+ steps.push({
56
+ type: "instruction",
57
+ title: "Framework-Specific Setup",
58
+ content: frameworkInstructions.setup,
59
+ });
60
+ }
61
+ if (frameworkInstructions.run && !isPercyAutomate) {
62
+ steps.push({
63
+ type: "instruction",
64
+ title: "Run the tests",
65
+ content: frameworkInstructions.run,
66
+ });
67
+ }
68
+ }
69
+ return {
70
+ steps,
71
+ requiresPercy: false,
72
+ missingDependencies: [],
73
+ };
74
+ }
@@ -0,0 +1,10 @@
1
+ export declare const IMPORTANT_SETUP_WARNING = "IMPORTANT: DO NOT SKIP ANY STEP. All the setup steps described below MUST be executed regardless of any existing configuration or setup. This ensures proper BrowserStack SDK setup.";
2
+ export declare const SETUP_PERCY_DESCRIPTION = "Set up Percy visual testing for your project. This supports both Percy Web Standalone and Percy Automate.";
3
+ export declare const LIST_TEST_FILES_DESCRIPTION = "Lists all test files for a given set of directories.";
4
+ export declare const PERCY_SNAPSHOT_COMMANDS_DESCRIPTION = "Adds Percy snapshot commands to the specified test files.";
5
+ export declare const RUN_ON_BROWSERSTACK_DESCRIPTION = "Set up and run automated web-based tests on BrowserStack using the BrowserStack SDK. Use this tool for functional or integration test setup on BrowserStack only. For any visual testing or Percy integration, use the dedicated Percy setup tool. Example prompts: run this test on browserstack; set up this project for browserstack.";
6
+ export declare const SIMULATE_PERCY_CHANGE_DESCRIPTION = "This tool helps new users simulate a Percy visual change by guiding them to make a visible UI modification, rerun Percy, and verify that the change is detected. Only Percy web is supported";
7
+ export declare const PERCY_REPLACE_REGEX: RegExp;
8
+ export declare const PERCY_SNAPSHOT_INSTRUCTION = "\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";
9
+ export declare const PERCY_SIMULATE_INSTRUCTION = "\nMANDATORY: Aggressive, Accurate Percy Snapshots Integration\n\nPrerequisite: Before making any code changes in the user's repo, switch to a branch named temp-percy (run git init first if the repo is not yet initialized).\n\nYou MUST follow these steps with NO EXCEPTIONS:\n1. Identify 4-5 key test files in the project that are critical for visual testing.\n2. For EACH identified test file, analyze the code to find EVERY location where a Percy snapshot should be called (e.g., after each navigation, UI change, or significant state in tests).\n3. Insert snapshot calls at ALL such points, not just the first or most obvious one.\n\nIteratively update every selected test file with percy snapshot calls at all identified points, ensuring comprehensive coverage of visual changes.";
10
+ export declare const PERCY_SIMULATION_DRIVER_INSTRUCTION = "\nMANDATORY: Step-by-Step Percy Visual Change Simulation\nYou MUST follow these steps with NO EXCEPTIONS:\n\nSTEP 1: At this case we have added Percy snapshot commands to the test files at the appropriate locations (e.g., after navigation, UI change, or significant state). \n- Use ONLY existing snapshot names.\n- Do NOT add any popup injection or visual changes yet.\n- Do NOT run any Percy builds at this stage.\n\nSTEP 2: Run ONE comprehensive baseline Percy build that executes ALL tests containing Percy snapshots in a SINGLE build. This creates one baseline build with all snapshots for comparison. Use a command like: npx percy exec -- python -m pytest tests/ -k 'test_name1 or test_name2 or test_name3' -v to run multiple specific tests in one build.\"\n\nSTEP 3: Modify your test to inject a visible UI change (such as a popup) IMMEDIATELY BEFORE an EXISTING snapshot command (e.g., before percy_snapshot(self.driver, \"screenshot name\")).\n- Do NOT add a new snapshot name for the popup.\n- The popup must appear in an existing snapshot, not a new one.\n- Add this popup code in some test files before the percy_snapshot command you've added, to display the visual changes.\n\n```Javascript\npopup_script = `\nvar popup = document.createElement('div');\npopup.id = 'percy-test-popup';\npopup.style.cssText = popup.style.cssText = `\n /* TODO: Add styles to make the popup large, centered, and visually noticeable.\n Suggested properties: position: fixed; top/left; transform; background; color; font-size; padding; z-index; animation, etc. */\n`;\npopup.innerHTML = 'PERCY TEST<br>VISUAL CHANGE<br>DETECTED!';\ndocument.body.appendChild(popup);\n`;\n\n# Insert this just before the EXISTING snapshot command:\ndriver.execute_script(popup_script)\npercy_snapshot(self.driver, \"Before Adding to Cart\") # (Do NOT change the snapshot name, keep existing one)\n```\n\nSTEP 4: Run a second Percy build.\n- The snapshot names must remain the same as in the baseline.\n- The visual change should now appear in the same snapshot as before.\n- Use the same build command you ran for the baseline.\n\nSTEP 5: Compare the two Percy builds to see the detected visual difference.\n\nSTEP 6: Now ask user if they want to setup percy for full project coverage? If yes, call the \"setupPercyVisualTesting\" tool to enable complete coverage for the entire project.\n\nCONSTRAINTS:\n- Do NOT run any builds until explicitly instructed in the steps.\n- Do NOT add new snapshot names\u2014only use existing ones.\n- Do NOT add popup injection until the baseline is established.\n- Visual changes must appear in EXISTING snapshots, not new ones.\n\nVALIDATION CHECKPOINTS (before proceeding to the next step):\n- Are you adding only snapshot commands (not running builds)?\n- Are you reusing existing snapshot names (not creating new ones)?\n- Have you established the baseline first (before adding visual changes)\n\nCRITICAL: \nDo NOT run tests separately or create multiple builds during baseline establishment. The goal is to have exactly TWO builds total: (1) baseline build with all original snapshots, (2) modified build with the same tests but visual changes injected.\n";
@@ -0,0 +1,86 @@
1
+ export const IMPORTANT_SETUP_WARNING = "IMPORTANT: DO NOT SKIP ANY STEP. All the setup steps described below MUST be executed regardless of any existing configuration or setup. This ensures proper BrowserStack SDK setup.";
2
+ export const SETUP_PERCY_DESCRIPTION = "Set up Percy visual testing for your project. This supports both Percy Web Standalone and Percy Automate.";
3
+ export const LIST_TEST_FILES_DESCRIPTION = "Lists all test files for a given set of directories.";
4
+ export const PERCY_SNAPSHOT_COMMANDS_DESCRIPTION = "Adds Percy snapshot commands to the specified test files.";
5
+ export const RUN_ON_BROWSERSTACK_DESCRIPTION = "Set up and run automated web-based tests on BrowserStack using the BrowserStack SDK. Use this tool for functional or integration test setup on BrowserStack only. For any visual testing or Percy integration, use the dedicated Percy setup tool. Example prompts: run this test on browserstack; set up this project for browserstack.";
6
+ export const SIMULATE_PERCY_CHANGE_DESCRIPTION = "This tool helps new users simulate a Percy visual change by guiding them to make a visible UI modification, rerun Percy, and verify that the change is detected. Only Percy web is supported";
7
+ export const PERCY_REPLACE_REGEX = /Invoke listTestFiles\(\) with the provided directories[\s\S]*?- DO NOT STOP until you add commands in all the files or you reach end of the files\./;
8
+ export const PERCY_SNAPSHOT_INSTRUCTION = `
9
+ Invoke listTestFiles() with the provided directories from user to gather all test files in memory and obtain the generated UUID ---STEP---
10
+ Process files in STRICT sequential order using tool addPercySnapshotCommands() with below instructions:
11
+ - Start with index 0
12
+ - Then index 1
13
+ - Then index 2
14
+ - Continue sequentially until the last index
15
+ - DO NOT skip any index numbers
16
+ - DO NOT jump to random indices like 10, 20, 30
17
+ - DO NOT worry about time consuming and any constraints.
18
+ - DO NOT STOP until you add commands in all the files or you reach end of the files.
19
+ `;
20
+ export const PERCY_SIMULATE_INSTRUCTION = `
21
+ MANDATORY: Aggressive, Accurate Percy Snapshots Integration
22
+
23
+ Prerequisite: Before making any code changes in the user's repo, switch to a branch named temp-percy (run git init first if the repo is not yet initialized).
24
+
25
+ You MUST follow these steps with NO EXCEPTIONS:
26
+ 1. Identify 4-5 key test files in the project that are critical for visual testing.
27
+ 2. For EACH identified test file, analyze the code to find EVERY location where a Percy snapshot should be called (e.g., after each navigation, UI change, or significant state in tests).
28
+ 3. Insert snapshot calls at ALL such points, not just the first or most obvious one.
29
+
30
+ Iteratively update every selected test file with percy snapshot calls at all identified points, ensuring comprehensive coverage of visual changes.`;
31
+ export const PERCY_SIMULATION_DRIVER_INSTRUCTION = `
32
+ MANDATORY: Step-by-Step Percy Visual Change Simulation
33
+ You MUST follow these steps with NO EXCEPTIONS:
34
+
35
+ STEP 1: At this case we have added Percy snapshot commands to the test files at the appropriate locations (e.g., after navigation, UI change, or significant state).
36
+ - Use ONLY existing snapshot names.
37
+ - Do NOT add any popup injection or visual changes yet.
38
+ - Do NOT run any Percy builds at this stage.
39
+
40
+ STEP 2: Run ONE comprehensive baseline Percy build that executes ALL tests containing Percy snapshots in a SINGLE build. This creates one baseline build with all snapshots for comparison. Use a command like: npx percy exec -- python -m pytest tests/ -k 'test_name1 or test_name2 or test_name3' -v to run multiple specific tests in one build."
41
+
42
+ STEP 3: Modify your test to inject a visible UI change (such as a popup) IMMEDIATELY BEFORE an EXISTING snapshot command (e.g., before percy_snapshot(self.driver, "screenshot name")).
43
+ - Do NOT add a new snapshot name for the popup.
44
+ - The popup must appear in an existing snapshot, not a new one.
45
+ - Add this popup code in some test files before the percy_snapshot command you've added, to display the visual changes.
46
+
47
+ \`\`\`Javascript
48
+ popup_script = \`
49
+ var popup = document.createElement('div');
50
+ popup.id = 'percy-test-popup';
51
+ popup.style.cssText = popup.style.cssText = \`
52
+ /* TODO: Add styles to make the popup large, centered, and visually noticeable.
53
+ Suggested properties: position: fixed; top/left; transform; background; color; font-size; padding; z-index; animation, etc. */
54
+ \`;
55
+ popup.innerHTML = 'PERCY TEST<br>VISUAL CHANGE<br>DETECTED!';
56
+ document.body.appendChild(popup);
57
+ \`;
58
+
59
+ # Insert this just before the EXISTING snapshot command:
60
+ driver.execute_script(popup_script)
61
+ percy_snapshot(self.driver, "Before Adding to Cart") # (Do NOT change the snapshot name, keep existing one)
62
+ \`\`\`
63
+
64
+ STEP 4: Run a second Percy build.
65
+ - The snapshot names must remain the same as in the baseline.
66
+ - The visual change should now appear in the same snapshot as before.
67
+ - Use the same build command you ran for the baseline.
68
+
69
+ STEP 5: Compare the two Percy builds to see the detected visual difference.
70
+
71
+ STEP 6: Now ask user if they want to setup percy for full project coverage? If yes, call the "setupPercyVisualTesting" tool to enable complete coverage for the entire project.
72
+
73
+ CONSTRAINTS:
74
+ - Do NOT run any builds until explicitly instructed in the steps.
75
+ - Do NOT add new snapshot names—only use existing ones.
76
+ - Do NOT add popup injection until the baseline is established.
77
+ - Visual changes must appear in EXISTING snapshots, not new ones.
78
+
79
+ VALIDATION CHECKPOINTS (before proceeding to the next step):
80
+ - Are you adding only snapshot commands (not running builds)?
81
+ - Are you reusing existing snapshot names (not creating new ones)?
82
+ - Have you established the baseline first (before adding visual changes)
83
+
84
+ CRITICAL:
85
+ Do NOT run tests separately or create multiple builds during baseline establishment. The goal is to have exactly TWO builds total: (1) baseline build with all original snapshots, (2) modified build with the same tests but visual changes injected.
86
+ `;
@@ -0,0 +1,5 @@
1
+ export declare function formatInstructionsWithNumbers(instructionText: string, separator?: string): {
2
+ formattedSteps: string;
3
+ stepCount: number;
4
+ };
5
+ export declare function generateVerificationMessage(stepCount: number): string;
@@ -0,0 +1,27 @@
1
+ export function formatInstructionsWithNumbers(instructionText, separator = "---STEP---") {
2
+ // Split the instructions by the separator
3
+ const steps = instructionText
4
+ .split(separator)
5
+ .map((step) => step.trim())
6
+ .filter((step) => step.length > 0);
7
+ // If no separators found, treat the entire text as one step
8
+ if (steps.length === 1 && !instructionText.includes(separator)) {
9
+ return {
10
+ formattedSteps: `**Step 1:**\n${instructionText.trim()}`,
11
+ stepCount: 1,
12
+ };
13
+ }
14
+ // Format each step with numbering
15
+ const formattedSteps = steps
16
+ .map((step, index) => {
17
+ return `**Step ${index + 1}:**\n${step.trim()}`;
18
+ })
19
+ .join("\n\n");
20
+ return {
21
+ formattedSteps,
22
+ stepCount: steps.length,
23
+ };
24
+ }
25
+ export function generateVerificationMessage(stepCount) {
26
+ return `**✅ Verification:**\nPlease verify that you have completed all ${stepCount} steps above to ensure proper setup. If you encounter any issues, double-check each step and ensure all commands executed successfully.`;
27
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./types.js";
2
+ export * from "./constants.js";
3
+ export * from "./formatUtils.js";
@@ -0,0 +1,4 @@
1
+ // Common utilities and types for SDK tools
2
+ export * from "./types.js";
3
+ export * from "./constants.js";
4
+ export * from "./formatUtils.js";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Core instruction configuration utilities for runTestsOnBrowserStack tool.
3
+ */
4
+ import { SDKSupportedLanguage, SDKSupportedBrowserAutomationFramework, SDKSupportedTestingFramework } from "./types.js";
5
+ export declare const getInstructionsForProjectConfiguration: (detectedBrowserAutomationFramework: SDKSupportedBrowserAutomationFramework, detectedTestingFramework: SDKSupportedTestingFramework, detectedLanguage: SDKSupportedLanguage, username: string, accessKey: string) => {
6
+ setup: string;
7
+ run: string;
8
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Core instruction configuration utilities for runTestsOnBrowserStack tool.
3
+ */
4
+ import { SUPPORTED_CONFIGURATIONS } from "../bstack/frameworks.js";
5
+ const errorMessageSuffix = "Please open an issue at our Github repo: https://github.com/browserstack/browserstack-mcp-server/issues to request support for your project configuration";
6
+ export const getInstructionsForProjectConfiguration = (detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage, username, accessKey) => {
7
+ const configuration = SUPPORTED_CONFIGURATIONS[detectedLanguage];
8
+ if (!configuration) {
9
+ throw new Error(`BrowserStack MCP Server currently does not support ${detectedLanguage}, ${errorMessageSuffix}`);
10
+ }
11
+ if (!configuration[detectedBrowserAutomationFramework]) {
12
+ throw new Error(`BrowserStack MCP Server currently does not support ${detectedBrowserAutomationFramework} for ${detectedLanguage}, ${errorMessageSuffix}`);
13
+ }
14
+ if (!configuration[detectedBrowserAutomationFramework][detectedTestingFramework]) {
15
+ throw new Error(`BrowserStack MCP Server currently does not support ${detectedTestingFramework} for ${detectedBrowserAutomationFramework} on ${detectedLanguage}, ${errorMessageSuffix}`);
16
+ }
17
+ const instructionFunction = configuration[detectedBrowserAutomationFramework][detectedTestingFramework]
18
+ .instructions;
19
+ return instructionFunction(username, accessKey);
20
+ };