Skip to content

Commit 93e3f4e

Browse files
Merge pull request #6 from tech-sushant/cont-regression
Cont regression
2 parents 669f086 + 0c34386 commit 93e3f4e

File tree

3 files changed

+263
-30
lines changed

3 files changed

+263
-30
lines changed

src/tools/bstack-sdk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ export default function addSDKTools(server: McpServer) {
121121
detectedTestingFramework: z
122122
.nativeEnum(SDKSupportedTestingFrameworkEnum)
123123
.describe(
124-
"The testing framework used in the project. Example: 'jest', 'pytest' 'webdriverio'",
124+
"The testing framework used in the project. Be precise with framework selection Example: 'webdriverio', 'jest', 'pytest', 'junit4', 'junit5', 'mocha'",
125125
),
126126
detectedLanguage: z
127127
.nativeEnum(SDKSupportedLanguageEnum)
128128
.describe(
129-
"The programming language used in the project. Example: 'nodejs', 'python', 'java'",
129+
"The programming language used in the project. Example: 'nodejs', 'python', 'java', 'csharp'",
130130
),
131131
desiredPlatforms: z
132132
.array(z.enum(["windows", "macos", "android", "ios"]))

src/tools/sdk-utils/constants.ts

Lines changed: 240 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import { ConfigMapping } from "./types.js";
22
import config from "../../config.js";
33

4-
const nodejsInstructions = `
5-
Run your test suite on BrowserStack
6-
Your test suite is now ready to run on BrowserStack! Run the commands added under the scripts property section in the package.json file. Here is an example command:
7-
8-
Terminal
9-
npm run [your-test-script-name]-browserstack
10-
If you don't see any new commands, make sure you ran npx setup correctly
11-
`;
4+
/**
5+
* ---------- PYTHON INSTRUCTIONS ----------
6+
*/
127

138
const pythonInstructions = `
149
Run the following command to install the browserstack-sdk:
@@ -27,6 +22,31 @@ browserstack-sdk python <path-to-test-file>
2722
\`\`\`
2823
`;
2924

25+
const generatePythonFrameworkInstructions = (framework: string) => `
26+
Run the following command to install the browserstack-sdk:
27+
\`\`\`bash
28+
python3 -m pip install browserstack-sdk
29+
\`\`\`
30+
31+
Run the following command to setup the browserstack-sdk:
32+
\`\`\`bash
33+
browserstack-sdk setup --framework "${framework}" --username "${config.browserstackUsername}" --key "${config.browserstackAccessKey}"
34+
\`\`\`
35+
36+
In order to run tests on BrowserStack, run the following command:
37+
\`\`\`bash
38+
browserstack-sdk ${framework} <path-to-test-files>
39+
\`\`\`
40+
`;
41+
42+
const robotInstructions = generatePythonFrameworkInstructions("robot");
43+
const behaveInstructions = generatePythonFrameworkInstructions("behave");
44+
const pytestInstructions = generatePythonFrameworkInstructions("pytest");
45+
46+
/**
47+
* ---------- JAVA INSTRUCTIONS ----------
48+
*/
49+
3050
const argsInstruction =
3151
'<argLine>-javaagent:"${com.browserstack:browserstack-java-sdk:jar}"</argLine>';
3252

@@ -67,6 +87,188 @@ gradle clean test
6787
\`\`\`
6888
`;
6989

90+
const generateJUnitInstructions = (framework: string) => `
91+
Set BrowserStack credentials as environment variables:
92+
\`\`\`bash
93+
export BROWSERSTACK_USERNAME="${config.browserstackUsername}"
94+
export BROWSERSTACK_ACCESS_KEY="${config.browserstackAccessKey}"
95+
\`\`\`
96+
97+
For Maven projects, run the following command to add browserstack-java-sdk dependency and browserstack.yml file:
98+
\`\`\`bash
99+
mvn archetype:generate -B -DarchetypeGroupId=com.browserstack \\
100+
-DarchetypeArtifactId=browserstack-sdk-archetype-integrate -DarchetypeVersion=1.0 \\
101+
-DgroupId=com.browserstack -DartifactId=browserstack-sdk-archetype-integrate -Dversion=1.0 \\
102+
-DBROWSERSTACK_USERNAME=${config.browserstackUsername} -DBROWSERSTACK_ACCESS_KEY=${config.browserstackAccessKey} \\
103+
-DBROWSERSTACK_FRAMEWORK=${framework}
104+
\`\`\`
105+
106+
For Gradle projects, add to build.gradle:
107+
\`\`\`groovy
108+
implementation 'com.browserstack:browserstack-java-sdk:latest.release'
109+
110+
def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
111+
112+
test {
113+
jvmArgs "-javaagent:\${browserstackSDKArtifact.file}"
114+
}
115+
\`\`\`
116+
117+
Run tests using:
118+
\`\`\`bash
119+
mvn clean test
120+
\`\`\`
121+
122+
Or for Gradle:
123+
\`\`\`bash
124+
gradle clean test
125+
\`\`\`
126+
`;
127+
128+
const junit4Instructions = generateJUnitInstructions("junit4");
129+
const junit5Instructions = generateJUnitInstructions("junit5");
130+
131+
/**
132+
* ---------- CSharp INSTRUCTIONS ----------
133+
*/
134+
135+
const csharpCommonInstructions = `
136+
1. Install BrowserStack TestAdapter NuGet package
137+
Add the package to your project:
138+
\`\`\`bash
139+
dotnet add package BrowserStack.TestAdapter
140+
\`\`\`
141+
142+
2. Build the project
143+
\`\`\`bash
144+
dotnet build
145+
\`\`\`
146+
147+
3. Set up BrowserStack SDK
148+
Replace the placeholders with your actual BrowserStack credentials:
149+
\`\`\`bash
150+
dotnet browserstack-sdk setup --userName ${config.browserstackUsername} --accessKey ${config.browserstackAccessKey}
151+
\`\`\`
152+
153+
4. Detect if you are running on Apple Silicon (macOS only)
154+
Run this check to determine if Apple Silicon-specific setup is required:
155+
\`\`\`bash
156+
ARCH="$(uname -m)"
157+
if [ "$ARCH" = "arm64" ]; then
158+
echo "Detected arm64 architecture - running Apple-Silicon flow"
159+
fi
160+
\`\`\`
161+
162+
5. macOS (Apple Silicon) setup (required only if arm64 detected)
163+
Install the x64 version of .NET for BrowserStack compatibility.
164+
165+
- Check your current .NET version:
166+
\`\`\`bash
167+
dotnet --version
168+
\`\`\`
169+
170+
- Ensure the path exists strictly; if not, create it first and then run the setup.
171+
\`\`\`bash
172+
sudo dotnet browserstack-sdk setup-dotnet --dotnet-path "<your-chosen-path>" --dotnet-version "<your-dotnet-version>"
173+
\`\`\`
174+
Common paths: /usr/local/share/dotnet, ~/dotnet-x64, or /opt/dotnet-x64
175+
176+
6. Run the tests
177+
- For macOS (Apple Silicon), use the full path:
178+
\`\`\`bash
179+
<your-chosen-path>/dotnet browserstack-sdk
180+
\`\`\`
181+
- For Windows, Intel Macs, or if dotnet alias is configured:
182+
\`\`\`bash
183+
dotnet test
184+
\`\`\`
185+
`;
186+
187+
const csharpPlaywrightCommonInstructions = `
188+
1. Install BrowserStack TestAdapter NuGet package
189+
Run the following command:
190+
\`\`\`bash
191+
dotnet add package BrowserStack.TestAdapter
192+
\`\`\`
193+
194+
2. Build the project
195+
\`\`\`bash
196+
dotnet build
197+
\`\`\`
198+
199+
3. Set up BrowserStack SDK
200+
Replace the placeholders with your actual credentials:
201+
\`\`\`bash
202+
dotnet browserstack-sdk setup --userName ${config.browserstackUsername} --accessKey ${config.browserstackAccessKey}
203+
\`\`\`
204+
205+
4. Supported browsers
206+
Use exactly one of the following (case-sensitive):
207+
\`chrome\`, \`edge\`, \`playwright-chromium\`, \`playwright-webkit\`, \`playwright-firefox\`
208+
209+
5. Detect if you are running on Apple Silicon (macOS only)
210+
Run this check to determine if Apple Silicon-specific setup is required:
211+
\`\`\`bash
212+
ARCH="$(uname -m)"
213+
if [ "$ARCH" = "arm64" ]; then
214+
echo "Detected arm64 architecture - running Apple-Silicon flow"
215+
fi
216+
\`\`\`
217+
218+
6. macOS (Apple Silicon) setup (required only if arm64 detected)
219+
Install the x64 version of .NET for compatibility with BrowserStack.
220+
221+
- Check your .NET version:
222+
\`\`\`bash
223+
dotnet --version
224+
\`\`\`
225+
226+
- Ensure the path exists strictly; if not, create it first and then run the setup.
227+
\`\`\`bash
228+
sudo dotnet browserstack-sdk setup-dotnet --dotnet-path "<your-chosen-path>" --dotnet-version "<your-dotnet-version>"
229+
\`\`\`
230+
Common paths: /usr/local/share/dotnet, ~/dotnet-x64, or /opt/dotnet-x64
231+
232+
7. Fix for Playwright architecture (macOS only)
233+
If the folder exists:
234+
\`<project-folder>/bin/Debug/net8.0/.playwright/node/darwin-arm64\`
235+
Rename \`darwin-arm64\` to \`darwin-x64\`
236+
237+
8. Run the tests
238+
- For macOS (Apple Silicon), use the full path:
239+
\`\`\`bash
240+
<your-chosen-path>/dotnet browserstack-sdk
241+
\`\`\`
242+
- For Windows, Intel Macs, or if dotnet alias is configured:
243+
\`\`\`bash
244+
dotnet test
245+
\`\`\`
246+
`;
247+
248+
/**
249+
* ---------- NODEJS INSTRUCTIONS ----------
250+
*/
251+
252+
const nodejsInstructions = `
253+
- Ensure that \`browserstack-node-sdk\` is present in package.json, use the latest version.
254+
- Add new scripts to package.json for running tests on BrowserStack (use \`npx\` to trigger the sdk):
255+
\`\`\`json
256+
"scripts": {
257+
"test:browserstack": "npx browserstack-node-sdk <framework-specific-test-execution-command>"
258+
}
259+
\`\`\`
260+
- Add to dependencies:
261+
\`\`\`json
262+
"browserstack-node-sdk": "latest"
263+
\`\`\`
264+
- Inform user to export BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY as environment variables.
265+
`;
266+
267+
/**
268+
* ---------- EXPORT CONFIG ----------
269+
*/
270+
271+
=======
70272
const webdriverioInstructions = `
71273
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.
72274
@@ -242,6 +444,36 @@ After the tests complete, you can view the results on your [BrowserStack Automat
242444
`;
243445

244446
export const SUPPORTED_CONFIGURATIONS: ConfigMapping = {
447+
python: {
448+
playwright: {
449+
pytest: { instructions: pythonInstructions },
450+
},
451+
selenium: {
452+
pytest: { instructions: pytestInstructions },
453+
robot: { instructions: robotInstructions },
454+
behave: { instructions: behaveInstructions },
455+
},
456+
},
457+
java: {
458+
playwright: {},
459+
selenium: {
460+
testng: { instructions: javaInstructions },
461+
cucumber: { instructions: javaInstructions },
462+
junit4: { instructions: junit4Instructions },
463+
junit5: { instructions: junit5Instructions },
464+
},
465+
},
466+
csharp: {
467+
playwright: {
468+
nunit: { instructions: csharpPlaywrightCommonInstructions },
469+
mstest: { instructions: csharpPlaywrightCommonInstructions },
470+
},
471+
selenium: {
472+
xunit: { instructions: csharpCommonInstructions },
473+
nunit: { instructions: csharpCommonInstructions },
474+
mstest: { instructions: csharpCommonInstructions },
475+
},
476+
},
245477
nodejs: {
246478
playwright: {
247479
jest: { instructions: nodejsInstructions },
@@ -260,24 +492,4 @@ export const SUPPORTED_CONFIGURATIONS: ConfigMapping = {
260492
cypress: { instructions: cypressInstructions },
261493
},
262494
},
263-
python: {
264-
playwright: {
265-
pytest: { instructions: pythonInstructions },
266-
},
267-
selenium: {
268-
pytest: { instructions: pythonInstructions },
269-
robot: { instructions: pythonInstructions },
270-
behave: { instructions: pythonInstructions },
271-
},
272-
cypress: {},
273-
},
274-
java: {
275-
playwright: {},
276-
selenium: {
277-
testng: { instructions: javaInstructions },
278-
cucumber: { instructions: javaInstructions },
279-
junit: { instructions: javaInstructions },
280-
},
281-
cypress: {},
282-
},
283495
};

src/tools/sdk-utils/types.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
export type SDKSupportedLanguage = "nodejs" | "python" | "java" | "csharp";
2+
export type SDKSupportedBrowserAutomationFramework = "playwright" | "selenium";
3+
export type SDKSupportedTestingFramework =
4+
| "jest"
5+
| "codeceptjs"
6+
| "playwright"
7+
| "pytest"
8+
| "robot"
9+
| "behave"
10+
| "cucumber"
11+
| "nightwatch"
12+
| "webdriverio"
13+
| "mocha"
14+
| "junit4"
15+
| "junit5"
16+
| "testng"
17+
| "xunit"
18+
| "nunit"
19+
| "mstest";
20+
21+
122
export enum SDKSupportedLanguageEnum {
223
nodejs = "nodejs",
324
python = "python",

0 commit comments

Comments
 (0)