@browserstack/mcp-server 1.1.8 → 1.2.0

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 (125) hide show
  1. package/README.md +71 -35
  2. package/dist/config.d.ts +13 -0
  3. package/dist/config.js +10 -6
  4. package/dist/index.d.ts +4 -0
  5. package/dist/index.js +20 -30
  6. package/dist/lib/api.d.ts +2 -0
  7. package/dist/lib/api.js +10 -5
  8. package/dist/lib/apiClient.d.ts +31 -0
  9. package/dist/lib/apiClient.js +108 -0
  10. package/dist/lib/constants.d.ts +17 -0
  11. package/dist/lib/device-cache.d.ts +9 -0
  12. package/dist/lib/device-cache.js +3 -3
  13. package/dist/lib/error.d.ts +7 -0
  14. package/dist/lib/fuzzy.d.ts +1 -0
  15. package/dist/lib/get-auth.d.ts +2 -0
  16. package/dist/lib/get-auth.js +8 -0
  17. package/dist/lib/inmemory-store.d.ts +1 -0
  18. package/dist/lib/instrumentation.d.ts +4 -0
  19. package/dist/lib/instrumentation.js +8 -7
  20. package/dist/lib/local.d.ts +3 -0
  21. package/dist/lib/local.js +12 -3
  22. package/dist/lib/types.d.ts +4 -0
  23. package/dist/lib/types.js +1 -0
  24. package/dist/lib/utils.d.ts +4 -0
  25. package/dist/lib/version-resolver.d.ts +6 -0
  26. package/dist/logger.d.ts +3 -0
  27. package/dist/logger.js +20 -4
  28. package/dist/oninitialized.d.ts +2 -0
  29. package/dist/oninitialized.js +2 -7
  30. package/dist/server-factory.d.ts +3 -0
  31. package/dist/server-factory.js +37 -0
  32. package/dist/tools/accessibility.d.ts +3 -0
  33. package/dist/tools/accessibility.js +17 -10
  34. package/dist/tools/accessiblity-utils/accessibility-rag.d.ts +12 -0
  35. package/dist/tools/accessiblity-utils/accessibility-rag.js +22 -12
  36. package/dist/tools/accessiblity-utils/report-fetcher.d.ts +8 -0
  37. package/dist/tools/accessiblity-utils/report-fetcher.js +26 -16
  38. package/dist/tools/accessiblity-utils/report-parser.d.ts +23 -0
  39. package/dist/tools/accessiblity-utils/report-parser.js +3 -3
  40. package/dist/tools/accessiblity-utils/scanner.d.ts +25 -0
  41. package/dist/tools/accessiblity-utils/scanner.js +46 -24
  42. package/dist/tools/appautomate-utils/appautomate.d.ts +42 -0
  43. package/dist/tools/appautomate-utils/appautomate.js +95 -9
  44. package/dist/tools/appautomate-utils/types.d.ts +5 -0
  45. package/dist/tools/appautomate-utils/types.js +6 -0
  46. package/dist/tools/appautomate.d.ts +3 -0
  47. package/dist/tools/appautomate.js +109 -13
  48. package/dist/tools/applive-utils/device-search.d.ts +6 -0
  49. package/dist/tools/applive-utils/start-session.d.ts +15 -0
  50. package/dist/tools/applive-utils/start-session.js +11 -4
  51. package/dist/tools/applive-utils/types.d.ts +7 -0
  52. package/dist/tools/applive-utils/upload-app.d.ts +5 -0
  53. package/dist/tools/applive-utils/upload-app.js +8 -12
  54. package/dist/tools/applive-utils/version-utils.d.ts +4 -0
  55. package/dist/tools/applive.d.ts +13 -0
  56. package/dist/tools/applive.js +6 -6
  57. package/dist/tools/automate-utils/fetch-screenshots.d.ts +6 -0
  58. package/dist/tools/automate-utils/fetch-screenshots.js +16 -12
  59. package/dist/tools/automate.d.ts +9 -0
  60. package/dist/tools/automate.js +6 -6
  61. package/dist/tools/bstack-sdk.d.ts +17 -0
  62. package/dist/tools/bstack-sdk.js +47 -20
  63. package/dist/tools/failurelogs-utils/app-automate.d.ts +7 -0
  64. package/dist/tools/failurelogs-utils/app-automate.js +29 -11
  65. package/dist/tools/failurelogs-utils/automate.d.ts +6 -0
  66. package/dist/tools/failurelogs-utils/automate.js +27 -12
  67. package/dist/tools/failurelogs-utils/utils.d.ts +30 -0
  68. package/dist/tools/getFailureLogs.d.ts +14 -0
  69. package/dist/tools/getFailureLogs.js +11 -11
  70. package/dist/tools/live-utils/desktop-filter.d.ts +2 -0
  71. package/dist/tools/live-utils/mobile-filter.d.ts +2 -0
  72. package/dist/tools/live-utils/start-session.d.ts +6 -0
  73. package/dist/tools/live-utils/start-session.js +18 -5
  74. package/dist/tools/live-utils/types.d.ts +33 -0
  75. package/dist/tools/live.d.ts +3 -0
  76. package/dist/tools/live.js +11 -11
  77. package/dist/tools/observability.d.ts +5 -0
  78. package/dist/tools/observability.js +14 -11
  79. package/dist/tools/sdk-utils/commands.d.ts +3 -0
  80. package/dist/tools/sdk-utils/commands.js +20 -5
  81. package/dist/tools/sdk-utils/constants.d.ts +2 -0
  82. package/dist/tools/sdk-utils/constants.js +284 -160
  83. package/dist/tools/sdk-utils/instructions.d.ts +6 -0
  84. package/dist/tools/sdk-utils/instructions.js +28 -6
  85. package/dist/tools/sdk-utils/percy/constants.d.ts +3 -0
  86. package/dist/tools/sdk-utils/percy/constants.js +36 -25
  87. package/dist/tools/sdk-utils/percy/instructions.d.ts +10 -0
  88. package/dist/tools/sdk-utils/percy/types.d.ts +5 -0
  89. package/dist/tools/sdk-utils/types.d.ts +39 -0
  90. package/dist/tools/sdk-utils/types.js +3 -0
  91. package/dist/tools/selfheal-utils/selfheal.d.ts +11 -0
  92. package/dist/tools/selfheal-utils/selfheal.js +10 -6
  93. package/dist/tools/selfheal.d.ts +7 -0
  94. package/dist/tools/selfheal.js +6 -6
  95. package/dist/tools/testmanagement-utils/TCG-utils/api.d.ts +34 -0
  96. package/dist/tools/testmanagement-utils/TCG-utils/api.js +57 -44
  97. package/dist/tools/testmanagement-utils/TCG-utils/config.d.ts +5 -0
  98. package/dist/tools/testmanagement-utils/TCG-utils/helpers.d.ts +13 -0
  99. package/dist/tools/testmanagement-utils/TCG-utils/helpers.js +2 -1
  100. package/dist/tools/testmanagement-utils/TCG-utils/types.d.ts +26 -0
  101. package/dist/tools/testmanagement-utils/add-test-result.d.ts +42 -0
  102. package/dist/tools/testmanagement-utils/add-test-result.js +23 -10
  103. package/dist/tools/testmanagement-utils/create-lca-steps.d.ts +100 -0
  104. package/dist/tools/testmanagement-utils/create-lca-steps.js +64 -55
  105. package/dist/tools/testmanagement-utils/create-project-folder.d.ts +31 -0
  106. package/dist/tools/testmanagement-utils/create-project-folder.js +31 -21
  107. package/dist/tools/testmanagement-utils/create-testcase.d.ts +122 -0
  108. package/dist/tools/testmanagement-utils/create-testcase.js +13 -10
  109. package/dist/tools/testmanagement-utils/create-testrun.d.ts +82 -0
  110. package/dist/tools/testmanagement-utils/create-testrun.js +11 -8
  111. package/dist/tools/testmanagement-utils/list-testcases.d.ts +30 -0
  112. package/dist/tools/testmanagement-utils/list-testcases.js +9 -7
  113. package/dist/tools/testmanagement-utils/list-testruns.d.ts +22 -0
  114. package/dist/tools/testmanagement-utils/list-testruns.js +9 -7
  115. package/dist/tools/testmanagement-utils/poll-lca-status.d.ts +11 -0
  116. package/dist/tools/testmanagement-utils/poll-lca-status.js +12 -8
  117. package/dist/tools/testmanagement-utils/testcase-from-file.d.ts +4 -0
  118. package/dist/tools/testmanagement-utils/testcase-from-file.js +6 -6
  119. package/dist/tools/testmanagement-utils/update-testrun.d.ts +40 -0
  120. package/dist/tools/testmanagement-utils/update-testrun.js +11 -7
  121. package/dist/tools/testmanagement-utils/upload-file.d.ts +20 -0
  122. package/dist/tools/testmanagement-utils/upload-file.js +8 -6
  123. package/dist/tools/testmanagement.d.ts +60 -0
  124. package/dist/tools/testmanagement.js +51 -53
  125. package/package.json +1 -1
@@ -1,35 +1,47 @@
1
- import config from "../../config.js";
2
1
  /**
3
2
  * ---------- PYTHON INSTRUCTIONS ----------
4
3
  */
5
- const pythonInstructions = `
6
- Run the following command to install the browserstack-sdk:
4
+ const pythonInstructions = (username, accessKey) => `
5
+ ---STEP---
6
+
7
+ Install the BrowserStack SDK:
7
8
  \`\`\`bash
8
9
  python3 -m pip install browserstack-sdk
9
10
  \`\`\`
10
11
 
11
- Run the following command to setup the browserstack-sdk:
12
+ ---STEP---
13
+
14
+ Setup the BrowserStack SDK with your credentials:
12
15
  \`\`\`bash
13
- browserstack-sdk setup --username "${config.browserstackUsername}" --key "${config.browserstackAccessKey}"
16
+ browserstack-sdk setup --username "${username}" --key "${accessKey}"
14
17
  \`\`\`
15
18
 
16
- In order to run tests on BrowserStack, run the following command:
19
+ ---STEP---
20
+
21
+ Run your tests on BrowserStack:
17
22
  \`\`\`bash
18
23
  browserstack-sdk python <path-to-test-file>
19
24
  \`\`\`
20
25
  `;
21
- const generatePythonFrameworkInstructions = (framework) => `
22
- Run the following command to install the browserstack-sdk:
26
+ const generatePythonFrameworkInstructions = (framework) => (username, accessKey) => `
27
+ ---STEP---
28
+
29
+ Install the BrowserStack SDK:
30
+
23
31
  \`\`\`bash
24
32
  python3 -m pip install browserstack-sdk
25
33
  \`\`\`
26
34
 
27
- Run the following command to setup the browserstack-sdk:
35
+ ---STEP---
36
+
37
+ Setup the BrowserStack SDK with framework-specific configuration:
28
38
  \`\`\`bash
29
- browserstack-sdk setup --framework "${framework}" --username "${config.browserstackUsername}" --key "${config.browserstackAccessKey}"
39
+ browserstack-sdk setup --framework "${framework}" --username "${username}" --key "${accessKey}"
30
40
  \`\`\`
31
41
 
32
- In order to run tests on BrowserStack, run the following command:
42
+ ---STEP---
43
+
44
+ Run your ${framework} tests on BrowserStack:
33
45
  \`\`\`bash
34
46
  browserstack-sdk ${framework} <path-to-test-files>
35
47
  \`\`\`
@@ -41,8 +53,10 @@ const pytestInstructions = generatePythonFrameworkInstructions("pytest");
41
53
  * ---------- JAVA INSTRUCTIONS ----------
42
54
  */
43
55
  const argsInstruction = '<argLine>-javaagent:"${com.browserstack:browserstack-java-sdk:jar}"</argLine>';
44
- const javaInstructions = `
45
- Strictly Add the following dependencies to your \`pom.xml\`:
56
+ const javaInstructions = (username, accessKey) => `
57
+ ---STEP---
58
+
59
+ Add the BrowserStack Java SDK dependency to your \`pom.xml\`:
46
60
  \`\`\`xml
47
61
  <dependency>
48
62
  <groupId>com.browserstack</groupId>
@@ -61,13 +75,17 @@ dependencies {
61
75
  }
62
76
  \`\`\`
63
77
 
64
- Inform user to export:
78
+ ---STEP---
79
+
80
+ Export your BrowserStack credentials as environment variables:
65
81
  \`\`\`bash
66
- export BROWSERSTACK_USERNAME=${config.browserstackUsername}
67
- export BROWSERSTACK_ACCESS_KEY=${config.browserstackAccessKey}
82
+ export BROWSERSTACK_USERNAME=${username}
83
+ export BROWSERSTACK_ACCESS_KEY=${accessKey}
68
84
  \`\`\`
69
85
 
70
- Run tests using:
86
+ ---STEP---
87
+
88
+ Run your tests using Maven:
71
89
  \`\`\`bash
72
90
  mvn clean test
73
91
  \`\`\`
@@ -77,168 +95,263 @@ Or for Gradle:
77
95
  gradle clean test
78
96
  \`\`\`
79
97
  `;
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
+ `;
80
154
  /**
81
155
  * ---------- CSharp INSTRUCTIONS ----------
82
156
  */
83
- const csharpCommonInstructions = `
84
- 1. Install BrowserStack TestAdapter NuGet package
85
- Add the package to your project:
86
- \`\`\`bash
87
- dotnet add package BrowserStack.TestAdapter
88
- \`\`\`
89
-
90
- 2. Build the project
91
- \`\`\`bash
92
- dotnet build
93
- \`\`\`
94
-
95
- 3. Set up BrowserStack SDK
96
- Replace the placeholders with your actual BrowserStack credentials:
97
- \`\`\`bash
98
- dotnet browserstack-sdk setup --userName ${config.browserstackUsername} --accessKey ${config.browserstackAccessKey}
99
- \`\`\`
100
-
101
- 4. Detect if you are running on Apple Silicon (macOS only)
102
- Run this check to determine if Apple Silicon-specific setup is required:
103
- \`\`\`bash
104
- ARCH="$(uname -m)"
105
- if [ "$ARCH" = "arm64" ]; then
106
- echo "Detected arm64 architecture - running Apple-Silicon flow"
107
- fi
108
- \`\`\`
109
-
110
- 5. macOS (Apple Silicon) setup (required only if arm64 detected)
111
- Install the x64 version of .NET for BrowserStack compatibility.
112
-
113
- - Check your current .NET version:
114
- \`\`\`bash
115
- dotnet --version
116
- \`\`\`
117
-
118
- - Ensure the path exists strictly; if not, create it first and then run the setup.
119
- \`\`\`bash
120
- sudo dotnet browserstack-sdk setup-dotnet --dotnet-path "<your-chosen-path>" --dotnet-version "<your-dotnet-version>"
121
- \`\`\`
122
- Common paths: /usr/local/share/dotnet, ~/dotnet-x64, or /opt/dotnet-x64
123
-
124
- 6. Run the tests
125
- - For macOS (Apple Silicon), use the full path:
126
- \`\`\`bash
127
- <your-chosen-path>/dotnet browserstack-sdk
128
- \`\`\`
129
- - For Windows, Intel Macs, or if dotnet alias is configured:
130
- \`\`\`bash
131
- dotnet test
132
- \`\`\`
157
+ const csharpCommonInstructions = (username, accessKey) => `
158
+ ---STEP---
159
+
160
+ Install BrowserStack TestAdapter NuGet package:
161
+ \`\`\`bash
162
+ dotnet add package BrowserStack.TestAdapter
163
+ \`\`\`
164
+
165
+ ---STEP---
166
+
167
+ Build the project:
168
+ \`\`\`bash
169
+ dotnet build
170
+ \`\`\`
171
+
172
+ ---STEP---
173
+
174
+ Set up BrowserStack SDK with your credentials:
175
+ \`\`\`bash
176
+ dotnet browserstack-sdk setup --userName ${username} --accessKey ${accessKey}
177
+ \`\`\`
178
+
179
+ ---STEP---
180
+
181
+ Detect if you are running on Apple Silicon (macOS only):
182
+ Run this check to determine if Apple Silicon-specific setup is required:
183
+ \`\`\`bash
184
+ ARCH="$(uname -m)"
185
+ if [ "$ARCH" = "arm64" ]; then
186
+ echo "Detected arm64 architecture - running Apple-Silicon flow"
187
+ fi
188
+ \`\`\`
189
+
190
+ ---STEP---
191
+
192
+ macOS (Apple Silicon) setup (Strictly follow if arm64 detected):
193
+ Install the x64 version of .NET for BrowserStack compatibility.
194
+
195
+ - Check your current .NET version:
196
+ \`\`\`bash
197
+ dotnet --version
198
+ \`\`\`
199
+
200
+ - Ensure the path exists strictly; if not, create it first and then run the setup:
201
+ This automatically installs the x64 version of .NET in the specified path. No need to install it from external sources.
202
+ \`\`\`bash
203
+ sudo dotnet browserstack-sdk setup-dotnet --dotnet-path "<your-chosen-path>" --dotnet-version "<your-dotnet-version>"
204
+ \`\`\`
205
+ Common paths: /usr/local/share/dotnet, ~/dotnet-x64, or /opt/dotnet-x64
206
+
207
+ ---STEP---
208
+
209
+ Run the tests:
210
+ - For macOS (Apple Silicon), use the full path where the x64 version of .NET is installed:
211
+ \`\`\`bash
212
+ <your-chosen-path>/dotnet browserstack-sdk
213
+ \`\`\`
214
+ - For Windows, Intel Macs, or if dotnet alias is configured:
215
+ \`\`\`bash
216
+ dotnet test
217
+ \`\`\`
133
218
  `;
134
- const csharpPlaywrightCommonInstructions = `
135
- 1. Install BrowserStack TestAdapter NuGet package
136
- Run the following command:
137
- \`\`\`bash
138
- dotnet add package BrowserStack.TestAdapter
139
- \`\`\`
140
-
141
- 2. Build the project
142
- \`\`\`bash
143
- dotnet build
144
- \`\`\`
145
-
146
- 3. Set up BrowserStack SDK
147
- Replace the placeholders with your actual credentials:
148
- \`\`\`bash
149
- dotnet browserstack-sdk setup --userName ${config.browserstackUsername} --accessKey ${config.browserstackAccessKey}
150
- \`\`\`
151
-
152
- 4. Supported browsers
153
- Use exactly one of the following (case-sensitive):
154
- \`chrome\`, \`edge\`, \`playwright-chromium\`, \`playwright-webkit\`, \`playwright-firefox\`
155
-
156
- 5. Detect if you are running on Apple Silicon (macOS only)
157
- Run this check to determine if Apple Silicon-specific setup is required:
158
- \`\`\`bash
159
- ARCH="$(uname -m)"
160
- if [ "$ARCH" = "arm64" ]; then
161
- echo "Detected arm64 architecture - running Apple-Silicon flow"
162
- fi
163
- \`\`\`
164
-
165
- 6. macOS (Apple Silicon) setup (required only if arm64 detected)
166
- Install the x64 version of .NET for compatibility with BrowserStack.
167
-
168
- - Check your .NET version:
169
- \`\`\`bash
170
- dotnet --version
171
- \`\`\`
172
-
173
- - Ensure the path exists strictly; if not, create it first and then run the setup.
174
- \`\`\`bash
175
- sudo dotnet browserstack-sdk setup-dotnet --dotnet-path "<your-chosen-path>" --dotnet-version "<your-dotnet-version>"
176
- \`\`\`
177
- Common paths: /usr/local/share/dotnet, ~/dotnet-x64, or /opt/dotnet-x64
178
-
179
- 7. Fix for Playwright architecture (macOS only)
180
- If the folder exists:
181
- \`<project-folder>/bin/Debug/net8.0/.playwright/node/darwin-arm64\`
182
- Rename \`darwin-arm64\` to \`darwin-x64\`
183
-
184
- 8. Run the tests
185
- - For macOS (Apple Silicon), use the full path:
186
- \`\`\`bash
187
- <your-chosen-path>/dotnet browserstack-sdk
188
- \`\`\`
189
- - For Windows, Intel Macs, or if dotnet alias is configured:
190
- \`\`\`bash
191
- dotnet test
192
- \`\`\`
219
+ const csharpPlaywrightCommonInstructions = (username, accessKey) => `
220
+ ---STEP---
221
+
222
+ Install BrowserStack TestAdapter NuGet package:
223
+ \`\`\`bash
224
+ dotnet add package BrowserStack.TestAdapter
225
+ \`\`\`
226
+
227
+ ---STEP---
228
+
229
+ Build the project:
230
+ \`\`\`bash
231
+ dotnet build
232
+ \`\`\`
233
+
234
+ ---STEP---
235
+
236
+ Set up BrowserStack SDK with your credentials:
237
+ \`\`\`bash
238
+ dotnet browserstack-sdk setup --userName ${username} --accessKey ${accessKey}
239
+ \`\`\`
240
+
241
+ ---STEP---
242
+
243
+ Choose supported browser:
244
+ Use exactly one of the following (case-sensitive):
245
+ \`chrome\`, \`edge\`, \`playwright-chromium\`, \`playwright-webkit\`, \`playwright-firefox\`
246
+
247
+ ---STEP---
248
+
249
+ Detect if you are running on Apple Silicon (macOS only):
250
+ Run this check to determine if Apple Silicon-specific setup is required:
251
+ \`\`\`bash
252
+ ARCH="$(uname -m)"
253
+ if [ "$ARCH" = "arm64" ]; then
254
+ echo "Detected arm64 architecture - running Apple-Silicon flow"
255
+ fi
256
+ \`\`\`
257
+
258
+ ---STEP---
259
+
260
+ macOS (Apple Silicon) setup (required only if arm64 detected):
261
+ Install the x64 version of .NET for compatibility with BrowserStack.
262
+
263
+ - Check your .NET version:
264
+ \`\`\`bash
265
+ dotnet --version
266
+ \`\`\`
267
+
268
+ - Ensure the path exists strictly; if not, create it first and then run the setup:
269
+ This automatically installs the x64 version of .NET in the specified path. No need to install it from external sources.
270
+ \`\`\`bash
271
+ sudo dotnet browserstack-sdk setup-dotnet --dotnet-path "<your-chosen-path>" --dotnet-version "<your-dotnet-version>"
272
+ \`\`\`
273
+ Common paths: /usr/local/share/dotnet, ~/dotnet-x64, or /opt/dotnet-x64
274
+
275
+ ---STEP---
276
+
277
+ Fix for Playwright architecture (macOS only):
278
+ If the folder exists:
279
+ \`<project-folder>/bin/Debug/net8.0/.playwright/node/darwin-arm64\`
280
+ Rename \`darwin-arm64\` to \`darwin-x64\`
281
+
282
+ ---STEP---
283
+
284
+ Run the tests:
285
+ - For macOS (Apple Silicon), use the full path:
286
+ \`\`\`bash
287
+ <your-chosen-path>/dotnet browserstack-sdk
288
+ \`\`\`
289
+ - For Windows, Intel Macs, or if dotnet alias is configured:
290
+ \`\`\`bash
291
+ dotnet test
292
+ \`\`\`
193
293
  `;
194
294
  /**
195
295
  * ---------- NODEJS INSTRUCTIONS ----------
196
296
  */
197
- const nodejsInstructions = `
198
- - Ensure that \`browserstack-node-sdk\` is present in package.json, use the latest version.
199
- - Add new scripts to package.json for running tests on BrowserStack (use \`npx\` to trigger the sdk):
200
- \`\`\`json
201
- "scripts": {
202
- "test:browserstack": "npx browserstack-node-sdk <framework-specific-test-execution-command>"
203
- }
204
- \`\`\`
205
- - Add to dependencies:
206
- \`\`\`json
207
- "browserstack-node-sdk": "latest"
208
- \`\`\`
209
- - Inform user to export BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY as environment variables.
297
+ const nodejsInstructions = (username, accessKey) => `
298
+ ---STEP---
299
+
300
+ Ensure \`browserstack-node-sdk\` is present in package.json with the latest version:
301
+ \`\`\`json
302
+ "browserstack-node-sdk": "latest"
303
+ \`\`\`
304
+
305
+ ---STEP---
306
+
307
+ Add new scripts to package.json for running tests on BrowserStack:
308
+ \`\`\`json
309
+ "scripts": {
310
+ "test:browserstack": "npx browserstack-node-sdk <framework-specific-test-execution-command>"
311
+ }
312
+ \`\`\`
313
+
314
+ ---STEP---
315
+
316
+ Export BrowserStack credentials as environment variables:
317
+ Set the following environment variables before running tests.
318
+ \`\`\`bash
319
+ export BROWSERSTACK_USERNAME=${username}
320
+ export BROWSERSTACK_ACCESS_KEY=${accessKey}
321
+ \`\`\`
210
322
  `;
211
323
  /**
212
324
  * ---------- EXPORT CONFIG ----------
213
325
  */
214
- const webdriverioInstructions = `
215
- To integrate your WebdriverIO test suite with BrowserStack, follow these steps. This process uses the @wdio/browserstack-service and does not require a browserstack.yml file.
216
-
217
- **1. Set BrowserStack Credentials**
326
+ const webdriverioInstructions = (username, accessKey) => `
327
+ ---STEP---
218
328
 
329
+ Set BrowserStack Credentials:
219
330
  Export your BrowserStack username and access key as environment variables.
220
331
 
221
332
  For macOS/Linux:
222
333
  \`\`\`bash
223
- export BROWSERSTACK_USERNAME= ${config.browserstackUsername}
224
- export BROWSERSTACK_ACCESS_KEY= ${config.browserstackAccessKey}
334
+ export BROWSERSTACK_USERNAME=${username}
335
+ export BROWSERSTACK_ACCESS_KEY=${accessKey}
225
336
  \`\`\`
226
337
 
227
338
  For Windows PowerShell:
228
339
  \`\`\`powershell
229
- $env:BROWSERSTACK_USERNAME=${config.browserstackUsername}
230
- $env:BROWSERSTACK_ACCESS_KEY=${config.browserstackAccessKey}
340
+ $env:BROWSERSTACK_USERNAME=${username}
341
+ $env:BROWSERSTACK_ACCESS_KEY=${accessKey}
231
342
  \`\`\`
232
343
 
233
- **2. Install the BrowserStack WDIO Service**
344
+ ---STEP---
234
345
 
346
+ Install the BrowserStack WDIO Service:
235
347
  Add the service to your project's dev dependencies.
236
348
  \`\`\`bash
237
349
  npm install @wdio/browserstack-service --save-dev
238
350
  \`\`\`
239
351
 
240
- **3. Update your WebdriverIO Config File (e.g., wdio.conf.js)**
352
+ ---STEP---
241
353
 
354
+ Update your WebdriverIO Config File (e.g., wdio.conf.js):
242
355
  Modify your configuration file to use the BrowserStack service and define the platforms you want to test on.
243
356
 
244
357
  Here is an example configuration:
@@ -310,29 +423,31 @@ exports.config.capabilities.forEach(function (caps) {
310
423
  });
311
424
  \`\`\`
312
425
 
313
- **4. Run your tests**
426
+ ---STEP---
314
427
 
428
+ Run your tests:
315
429
  You can now run your tests on BrowserStack using your standard WebdriverIO command.
316
430
  `;
317
- const cypressInstructions = `
318
- To integrate your Cypress test suite with BrowserStack, follow these steps. This process uses the BrowserStack Cypress CLI and a \`browserstack.json\` file for configuration.
319
-
320
- **1. Install the BrowserStack Cypress CLI**
431
+ const cypressInstructions = (username, accessKey) => `
432
+ ---STEP---
321
433
 
434
+ Install the BrowserStack Cypress CLI:
322
435
  Install the CLI as a dev dependency in your project.
323
436
  \`\`\`bash
324
437
  npm install browserstack-cypress-cli --save-dev
325
438
  \`\`\`
326
439
 
327
- **2. Create the Configuration File**
440
+ ---STEP---
328
441
 
442
+ Create the Configuration File:
329
443
  Generate the \`browserstack.json\` configuration file in your project's root directory by running the following command:
330
444
  \`\`\`bash
331
445
  npx browserstack-cypress init
332
446
  \`\`\`
333
447
 
334
- **3. Configure \`browserstack.json\`**
448
+ ---STEP---
335
449
 
450
+ Configure \`browserstack.json\`:
336
451
  Open the generated \`browserstack.json\` file and update it with your BrowserStack credentials and desired capabilities. Below is an example configuration.
337
452
 
338
453
  * **auth**: Your BrowserStack username and access key.
@@ -342,8 +457,8 @@ Open the generated \`browserstack.json\` file and update it with your BrowserSta
342
457
  \`\`\`json
343
458
  {
344
459
  "auth": {
345
- "username": "${config.browserstackUsername}",
346
- "access_key": "${config.browserstackAccessKey}"
460
+ "username": "${username}",
461
+ "access_key": "${accessKey}"
347
462
  },
348
463
  "browsers": [
349
464
  {
@@ -372,10 +487,12 @@ Open the generated \`browserstack.json\` file and update it with your BrowserSta
372
487
  }
373
488
  }
374
489
  \`\`\`
490
+
375
491
  **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.
376
492
 
377
- **4. Run Your Tests on BrowserStack**
493
+ ---STEP---
378
494
 
495
+ Run Your Tests on BrowserStack:
379
496
  Execute your tests on BrowserStack using the following command:
380
497
  \`\`\`bash
381
498
  npx browserstack-cypress run --sync
@@ -395,12 +512,17 @@ export const SUPPORTED_CONFIGURATIONS = {
395
512
  },
396
513
  },
397
514
  java: {
398
- playwright: {},
515
+ playwright: {
516
+ junit4: { instructions: javaInstructions },
517
+ junit5: { instructions: javaInstructions },
518
+ testng: { instructions: javaInstructions },
519
+ },
399
520
  selenium: {
400
521
  testng: { instructions: javaInstructions },
401
522
  cucumber: { instructions: javaInstructions },
402
523
  junit4: { instructions: javaInstructions },
403
524
  junit5: { instructions: javaInstructions },
525
+ serenity: { instructions: serenityInstructions },
404
526
  },
405
527
  },
406
528
  csharp: {
@@ -412,6 +534,8 @@ export const SUPPORTED_CONFIGURATIONS = {
412
534
  xunit: { instructions: csharpCommonInstructions },
413
535
  nunit: { instructions: csharpCommonInstructions },
414
536
  mstest: { instructions: csharpCommonInstructions },
537
+ specflow: { instructions: csharpCommonInstructions },
538
+ reqnroll: { instructions: csharpCommonInstructions },
415
539
  },
416
540
  },
417
541
  nodejs: {
@@ -0,0 +1,6 @@
1
+ import { SDKSupportedLanguage } from "./types.js";
2
+ import { SDKSupportedBrowserAutomationFramework } from "./types.js";
3
+ import { SDKSupportedTestingFramework } from "./types.js";
4
+ export declare const getInstructionsForProjectConfiguration: (detectedBrowserAutomationFramework: SDKSupportedBrowserAutomationFramework, detectedTestingFramework: SDKSupportedTestingFramework, detectedLanguage: SDKSupportedLanguage, username: string, accessKey: string) => string;
5
+ export declare function generateBrowserStackYMLInstructions(desiredPlatforms: string[], enablePercy?: boolean): string;
6
+ export declare function formatInstructionsWithNumbers(instructionText: string, separator?: string): string;
@@ -1,6 +1,6 @@
1
1
  import { SUPPORTED_CONFIGURATIONS } from "./constants.js";
2
2
  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";
3
- export const getInstructionsForProjectConfiguration = (detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage) => {
3
+ export const getInstructionsForProjectConfiguration = (detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage, username, accessKey) => {
4
4
  const configuration = SUPPORTED_CONFIGURATIONS[detectedLanguage];
5
5
  if (!configuration) {
6
6
  throw new Error(`BrowserStack MCP Server currently does not support ${detectedLanguage}, ${errorMessageSuffix}`);
@@ -11,17 +11,19 @@ export const getInstructionsForProjectConfiguration = (detectedBrowserAutomation
11
11
  if (!configuration[detectedBrowserAutomationFramework][detectedTestingFramework]) {
12
12
  throw new Error(`BrowserStack MCP Server currently does not support ${detectedTestingFramework} for ${detectedBrowserAutomationFramework} on ${detectedLanguage}, ${errorMessageSuffix}`);
13
13
  }
14
- return configuration[detectedBrowserAutomationFramework][detectedTestingFramework].instructions;
14
+ const instructionFunction = configuration[detectedBrowserAutomationFramework][detectedTestingFramework]
15
+ .instructions;
16
+ return instructionFunction(username, accessKey);
15
17
  };
16
18
  export function generateBrowserStackYMLInstructions(desiredPlatforms, enablePercy = false) {
17
19
  let ymlContent = `
18
20
  # ======================
19
21
  # BrowserStack Reporting
20
22
  # ======================
21
- # A single name for your project to organize all your tests. This is required for Percy.
22
- projectName: BrowserStack Sample
23
- # A name for the group of tests you are running
24
- buildName: mcp-run
23
+ # Project and build names help organize your test runs in BrowserStack dashboard and Percy.
24
+ # TODO: Replace these sample values with your actual project details
25
+ projectName: Sample Project
26
+ buildName: Sample Build
25
27
 
26
28
  # =======================================
27
29
  # Platforms (Browsers / Devices to test)
@@ -75,3 +77,23 @@ percyCaptureMode: manual`;
75
77
  \`\`\`
76
78
  \n`;
77
79
  }
80
+ export function formatInstructionsWithNumbers(instructionText, separator = "---STEP---") {
81
+ // Split the instructions by the separator
82
+ const steps = instructionText
83
+ .split(separator)
84
+ .map((step) => step.trim())
85
+ .filter((step) => step.length > 0);
86
+ // If no separators found, treat the entire text as one step
87
+ if (steps.length === 1 && !instructionText.includes(separator)) {
88
+ return `**Step 1:**\n${instructionText.trim()}\n\n**✅ Verification:**\nPlease verify that you have completed all the steps above to ensure proper setup.`;
89
+ }
90
+ // Format each step with numbering
91
+ const formattedSteps = steps
92
+ .map((step, index) => {
93
+ return `**Step ${index + 1}:**\n${step.trim()}`;
94
+ })
95
+ .join("\n\n");
96
+ // Add verification statement at the end
97
+ const verificationText = `\n\n**✅ Verification:**\nPlease verify that you have completed all ${steps.length} steps above to ensure proper setup. If you encounter any issues, double-check each step and ensure all commands executed successfully.`;
98
+ return formattedSteps + verificationText;
99
+ }
@@ -0,0 +1,3 @@
1
+ import { PercyConfigMapping } from "./types.js";
2
+ export declare const nodejsSeleniumInstructions = "\nImport the BrowserStack Percy SDK in your test script:\nAdd the Percy import to your test file.\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.snapshot(driver, \"My Snapshot\")\n // ....\n });\n})\n```\n";
3
+ export declare const PERCY_INSTRUCTIONS: PercyConfigMapping;