@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,78 @@
1
+ // C# instructions and commands for App SDK utilities
2
+ import { PLATFORM_UTILS, createStep, createEnvStep, combineInstructions, } from "../index.js";
3
+ export function getCSharpAppInstructions() {
4
+ const { isWindows, isAppleSilicon, getPlatformLabel } = PLATFORM_UTILS;
5
+ let runCommand = "";
6
+ if (isWindows) {
7
+ runCommand = `\`\`\`cmd
8
+ dotnet build
9
+ dotnet test --filter <EXPRESSION> [other_args]
10
+ \`\`\``;
11
+ }
12
+ else if (isAppleSilicon) {
13
+ runCommand = `\`\`\`bash
14
+ dotnet build
15
+ dotnet test --filter <EXPRESSION> [other_args]
16
+ \`\`\`
17
+
18
+ **Did not set the alias?**
19
+ Use the absolute path to the dotnet installation to run your tests on Mac computers with Apple silicon chips:
20
+ \`\`\`bash
21
+ </absolute/path/to/location/of/dotnet/>/dotnet test
22
+ \`\`\``;
23
+ }
24
+ else {
25
+ runCommand = `\`\`\`bash
26
+ dotnet build
27
+ dotnet test --filter <EXPRESSION> [other_args]
28
+ \`\`\``;
29
+ }
30
+ const runStep = createStep("Run your C# test suite:", `**${getPlatformLabel()}:**
31
+ ${runCommand}
32
+
33
+ **Debug Guidelines:**
34
+ If you encounter the error: java.lang.IllegalArgumentException: Multiple entries with the same key,
35
+ __Resolution:__
36
+ - The app capability should only be set in one place: browserstack.yml.
37
+ - Remove or comment out any code or configuration in your test setup (e.g., step definitions, runners, or capabilities setup) that sets the app path directly.`);
38
+ return runStep;
39
+ }
40
+ export function getCSharpSDKCommand(username, accessKey) {
41
+ const { isWindows = false, isAppleSilicon = false, getPlatformLabel = () => "Unknown", } = PLATFORM_UTILS || {};
42
+ if (!PLATFORM_UTILS) {
43
+ console.warn("PLATFORM_UTILS is undefined. Defaulting platform values.");
44
+ }
45
+ const envStep = createEnvStep(username, accessKey, isWindows, getPlatformLabel());
46
+ const installCommands = isWindows
47
+ ? `\`\`\`cmd
48
+ dotnet add package BrowserStack.TestAdapter
49
+ dotnet build
50
+ dotnet browserstack-sdk setup --userName "${username}" --accessKey "${accessKey}"
51
+ \`\`\``
52
+ : `\`\`\`bash
53
+ dotnet add package BrowserStack.TestAdapter
54
+ dotnet build
55
+ dotnet browserstack-sdk setup --userName "${username}" --accessKey "${accessKey}"
56
+ \`\`\``;
57
+ const installStep = createStep("Install BrowserStack SDK", `Run the following command to install the BrowserStack SDK and create a browserstack.yml file in the root directory of your project:
58
+
59
+ **${getPlatformLabel()}:**
60
+ ${installCommands}`);
61
+ const appleSiliconNote = isAppleSilicon
62
+ ? createStep("[Only for Macs with Apple silicon] Install dotnet x64 on MacOS", `If you are using a Mac computer with Apple silicon chip (M1 or M2) architecture, use the given command:
63
+
64
+ \`\`\`bash
65
+ cd #(project folder Android or iOS)
66
+ dotnet browserstack-sdk setup-dotnet --dotnet-path "<path>" --dotnet-version "<version>"
67
+ \`\`\`
68
+
69
+ - \`<path>\` - Mention the absolute path to the directory where you want to save dotnet x64
70
+ - \`<version>\` - Mention the dotnet version which you want to use to run tests
71
+
72
+ This command performs the following functions:
73
+ - Installs dotnet x64
74
+ - Installs the required version of dotnet x64 at an appropriate path
75
+ - Sets alias for the dotnet installation location on confirmation (enter y option)`)
76
+ : "";
77
+ return combineInstructions(envStep, installStep, appleSiliconNote);
78
+ }
@@ -0,0 +1,8 @@
1
+ export declare const MAVEN_ARCHETYPE_GROUP_ID = "com.browserstack";
2
+ export declare const MAVEN_ARCHETYPE_ARTIFACT_ID = "junit-archetype-integrate";
3
+ export declare const MAVEN_ARCHETYPE_VERSION = "1.0";
4
+ export declare const JAVA_APP_FRAMEWORK_MAP: Record<string, string>;
5
+ export declare const GRADLE_APP_SETUP_INSTRUCTIONS = "\n**For Gradle setup:**\n1. Add browserstack-java-sdk to dependencies:\n compileOnly 'com.browserstack:browserstack-java-sdk:latest.release'\n\n2. Add browserstackSDK path variable:\n def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }\n\n3. Add javaagent to gradle tasks:\n jvmArgs \"-javaagent:${browserstackSDKArtifact.file}\"\n";
6
+ export declare function getJavaAppInstructions(): string;
7
+ export declare function getJavaAppFrameworkForMaven(framework: string): string;
8
+ export declare function getJavaSDKCommand(framework: string, username: string, accessKey: string, appPath?: string): string;
@@ -0,0 +1,87 @@
1
+ // Java instructions and commands for App SDK utilities
2
+ import { createStep, combineInstructions, createEnvStep, PLATFORM_UTILS, } from "../index.js";
3
+ // Java-specific constants and mappings
4
+ export const MAVEN_ARCHETYPE_GROUP_ID = "com.browserstack";
5
+ export const MAVEN_ARCHETYPE_ARTIFACT_ID = "junit-archetype-integrate";
6
+ export const MAVEN_ARCHETYPE_VERSION = "1.0";
7
+ // Framework mapping for Java Maven archetype generation for App Automate
8
+ export const JAVA_APP_FRAMEWORK_MAP = {
9
+ testng: "browserstack-sdk-archetype-integrate",
10
+ junit5: "browserstack-sdk-archetype-integrate",
11
+ selenide: "selenide-archetype-integrate",
12
+ jbehave: "browserstack-sdk-archetype-integrate",
13
+ cucumberTestng: "browserstack-sdk-archetype-integrate",
14
+ cucumberJunit4: "browserstack-sdk-archetype-integrate",
15
+ cucumberJunit5: "browserstack-sdk-archetype-integrate",
16
+ };
17
+ // Common Gradle setup instructions for App Automate (platform-independent)
18
+ export const GRADLE_APP_SETUP_INSTRUCTIONS = `
19
+ **For Gradle setup:**
20
+ 1. Add browserstack-java-sdk to dependencies:
21
+ compileOnly 'com.browserstack:browserstack-java-sdk:latest.release'
22
+
23
+ 2. Add browserstackSDK path variable:
24
+ def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
25
+
26
+ 3. Add javaagent to gradle tasks:
27
+ jvmArgs "-javaagent:\${browserstackSDKArtifact.file}"
28
+ `;
29
+ export function getJavaAppInstructions() {
30
+ const baseRunStep = createStep("Run your App Automate test suite:", `\`\`\`bash
31
+ mvn test
32
+ \`\`\``);
33
+ return baseRunStep;
34
+ }
35
+ export function getJavaAppFrameworkForMaven(framework) {
36
+ return JAVA_APP_FRAMEWORK_MAP[framework] || framework;
37
+ }
38
+ function getMavenCommandForWindows(framework, mavenFramework, username, accessKey) {
39
+ return (`mvn archetype:generate -B ` +
40
+ `-DarchetypeGroupId="${MAVEN_ARCHETYPE_GROUP_ID}" ` +
41
+ `-DarchetypeArtifactId="${mavenFramework}" ` +
42
+ `-DarchetypeVersion="${MAVEN_ARCHETYPE_VERSION}" ` +
43
+ `-DgroupId="${MAVEN_ARCHETYPE_GROUP_ID}" ` +
44
+ `-DartifactId="${MAVEN_ARCHETYPE_ARTIFACT_ID}" ` +
45
+ `-Dversion="${MAVEN_ARCHETYPE_VERSION}" ` +
46
+ `-DBROWSERSTACK_USERNAME="${username}" ` +
47
+ `-DBROWSERSTACK_ACCESS_KEY="${accessKey}" ` +
48
+ `-DBROWSERSTACK_FRAMEWORK="${framework}"`);
49
+ }
50
+ function getMavenCommandForUnix(framework, mavenFramework, username, accessKey) {
51
+ return (`mvn archetype:generate -B ` +
52
+ `-DarchetypeGroupId="${MAVEN_ARCHETYPE_GROUP_ID}" ` +
53
+ `-DarchetypeArtifactId="${mavenFramework}" ` +
54
+ `-DarchetypeVersion="${MAVEN_ARCHETYPE_VERSION}" ` +
55
+ `-DgroupId="${MAVEN_ARCHETYPE_GROUP_ID}" ` +
56
+ `-DartifactId="${MAVEN_ARCHETYPE_ARTIFACT_ID}" ` +
57
+ `-Dversion="${MAVEN_ARCHETYPE_VERSION}" ` +
58
+ `-DBROWSERSTACK_USERNAME="${username}" ` +
59
+ `-DBROWSERSTACK_ACCESS_KEY="${accessKey}" ` +
60
+ `-DBROWSERSTACK_FRAMEWORK="${framework}"`);
61
+ }
62
+ export function getJavaSDKCommand(framework, username, accessKey, appPath) {
63
+ const { isWindows = false, getPlatformLabel } = PLATFORM_UTILS || {};
64
+ const mavenFramework = getJavaAppFrameworkForMaven(framework);
65
+ let mavenCommand;
66
+ if (isWindows) {
67
+ mavenCommand = getMavenCommandForWindows(framework, mavenFramework, username, accessKey);
68
+ if (appPath) {
69
+ mavenCommand += ` -DBROWSERSTACK_APP="${appPath}"`;
70
+ }
71
+ }
72
+ else {
73
+ mavenCommand = getMavenCommandForUnix(framework, mavenFramework, username, accessKey);
74
+ if (appPath) {
75
+ mavenCommand += ` -DBROWSERSTACK_APP="${appPath}"`;
76
+ }
77
+ }
78
+ const envStep = createEnvStep(username, accessKey, isWindows, getPlatformLabel());
79
+ const mavenStep = createStep("Install BrowserStack SDK using Maven Archetype for App Automate", `Maven command for ${framework} (${getPlatformLabel()}):
80
+ \`\`\`bash
81
+ ${mavenCommand}
82
+ \`\`\`
83
+
84
+ Alternative setup for Gradle users:
85
+ ${GRADLE_APP_SETUP_INSTRUCTIONS}`);
86
+ return combineInstructions(envStep, mavenStep);
87
+ }
@@ -0,0 +1,3 @@
1
+ import { AppSDKSupportedTestingFramework } from "../index.js";
2
+ export declare function getNodejsSDKCommand(testingFramework: string, username: string, accessKey: string): string;
3
+ export declare function getNodejsAppInstructions(testingFramework: AppSDKSupportedTestingFramework): string;
@@ -0,0 +1,194 @@
1
+ // Node.js instructions and commands for App SDK utilities
2
+ import { AppSDKSupportedTestingFrameworkEnum, createStep, combineInstructions, } from "../index.js";
3
+ export function getNodejsSDKCommand(testingFramework, username, accessKey) {
4
+ switch (testingFramework) {
5
+ case "webdriverio":
6
+ return getWebDriverIOCommand(username, accessKey);
7
+ case "nightwatch":
8
+ return getNightwatchCommand(username, accessKey);
9
+ case "jest":
10
+ return getJestCommand(username, accessKey);
11
+ case "mocha":
12
+ return getMochaCommand(username, accessKey);
13
+ case "cucumberJs":
14
+ return getCucumberJSCommand(username, accessKey);
15
+ default:
16
+ return "";
17
+ }
18
+ }
19
+ export function getNodejsAppInstructions(testingFramework) {
20
+ switch (testingFramework) {
21
+ case AppSDKSupportedTestingFrameworkEnum.webdriverio:
22
+ return createStep("Run your WebdriverIO test suite:", "Your test suite is now ready to run on BrowserStack. Use the commands defined in your package.json file to run the tests");
23
+ case AppSDKSupportedTestingFrameworkEnum.nightwatch:
24
+ return createStep("Run your App Automate test suite:", `For Android:
25
+ \`\`\`bash
26
+ npx nightwatch <path to tests> --env browserstack.android
27
+ \`\`\`
28
+ For iOS:
29
+ \`\`\`bash
30
+ npx nightwatch <path to tests> --env browserstack.ios
31
+ \`\`\``);
32
+ case AppSDKSupportedTestingFrameworkEnum.jest:
33
+ return createStep("Run your Jest test suite with BrowserStack SDK:", `Use the npm script defined in your package.json. For example:\n\n\`\`\`bash\nnpx run browserstack-node-sdk jest specs/single_test.js\n\`\`\``);
34
+ case AppSDKSupportedTestingFrameworkEnum.mocha:
35
+ return createStep("Run your Mocha test suite with BrowserStack SDK:", `Use the npm script defined in your package.json. For example:\n\n\`\`\`bash\nnpx run browserstack-node-sdk mocha specs/single_test.js\n\`\`\``);
36
+ case AppSDKSupportedTestingFrameworkEnum.cucumberJs:
37
+ return createStep("Run your Cucumber JS test suite with BrowserStack SDK:", `Use the npm script defined in your package.json. For example:\n\n\`\`\`bash\nnpx run browserstack-node-sdk cucumber-js specs/single_test.js\n\`\`\``);
38
+ default:
39
+ return "";
40
+ }
41
+ }
42
+ function getWebDriverIOCommand(username, accessKey) {
43
+ const prerequisiteStep = createStep("Prerequisite Setup:", `a. Ensure you do not modify or replace any existing local driver code,
44
+ as it will be automatically managed and overwritten by the BrowserStack SDK/Driver.
45
+ b. Do not create any YML file in this integration as it is not required.
46
+ c. Ensure you create the WDIO config file as per the instructions below.`);
47
+ const envStep = createStep("Set your BrowserStack credentials as environment variables:", `\`\`\`bash
48
+ export BROWSERSTACK_USERNAME=${username}
49
+ export BROWSERSTACK_ACCESS_KEY=${accessKey}
50
+ \`\`\``);
51
+ const installStep = createStep("Install BrowserStack WDIO service:", `\`\`\`bash
52
+ npm install @wdio/browserstack-service@^7 --save-dev
53
+ \`\`\``);
54
+ const configStep = createStep("Update your WebdriverIO config file (e.g., \\`wdio.conf.js\\`) to add the BrowserStack service and capabilities:", `\`\`\`js
55
+ exports.config = {
56
+ user: process.env.BROWSERSTACK_USERNAME || '${username}',
57
+ key: process.env.BROWSERSTACK_ACCESS_KEY || '${accessKey}',
58
+ hostname: 'hub.browserstack.com',
59
+ services: [
60
+ [
61
+ 'browserstack',
62
+ {
63
+ app: 'bs://sample.app',
64
+ browserstackLocal: true,
65
+ accessibility: false,
66
+ testObservabilityOptions: {
67
+ buildName: "bstack-demo",
68
+ projectName: "BrowserStack Sample",
69
+ buildTag: 'Any build tag goes here. For e.g. ["Tag1","Tag2"]'
70
+ },
71
+ },
72
+ ]
73
+ ],
74
+ capabilities: [{
75
+ 'bstack:options': {
76
+ deviceName: 'Samsung Galaxy S22 Ultra',
77
+ platformVersion: '12.0',
78
+ platformName: 'android',
79
+ }
80
+ }],
81
+ commonCapabilities: {
82
+ 'bstack:options': {
83
+ debug: true,
84
+ networkLogs: true,
85
+ percy: false,
86
+ percyCaptureMode: 'auto'
87
+ }
88
+ },
89
+ maxInstances: 10,
90
+ // ...other config
91
+ };
92
+ \`\`\``);
93
+ return combineInstructions(prerequisiteStep, envStep, installStep, configStep);
94
+ }
95
+ function getNightwatchCommand(username, accessKey) {
96
+ const prerequisiteStep = createStep("Prerequisite Setup:", ` a. Ensure you do not modify or replace any existing local driver code,
97
+ as it will be automatically managed and overwritten by the BrowserStack SDK/Driver.
98
+ b. Do not create any YML file in this integration as it is not required.
99
+ c. Ensure you create the WDIO config file as per the instructions below.`);
100
+ const envStep = createStep("Set your BrowserStack credentials as environment variables:", `\`\`\`bash
101
+ export BROWSERSTACK_USERNAME=${username}
102
+ export BROWSERSTACK_ACCESS_KEY=${accessKey}
103
+ \`\`\``);
104
+ const installStep = createStep("Install Nightwatch and BrowserStack integration:", `\`\`\`bash
105
+ npm install --save-dev @nightwatch/browserstack
106
+ \`\`\``);
107
+ const configStep = createStep("Update your Nightwatch config file (e.g., \\`nightwatch.conf.js\\`) to add the BrowserStack settings and capabilities:", `\`\`\`js
108
+
109
+ test_settings:{
110
+ ...
111
+ browserstack: {
112
+ selenium: {
113
+ host: 'hub.browserstack.com',
114
+ port: 443
115
+ },
116
+ desiredCapabilities: {
117
+ 'bstack:options': {
118
+ userName: '',
119
+ accessKey: '',
120
+ appiumVersion: '2.0.0'
121
+ }
122
+ },
123
+ disable_error_log: false,
124
+ webdriver: {
125
+ timeout_options: {
126
+ timeout: 60000,
127
+ retry_attempts: 3
128
+ },
129
+ keep_alive: true,
130
+ start_process: false
131
+ }
132
+ },
133
+ 'browserstack.android': {
134
+ extends: 'browserstack',
135
+ 'desiredCapabilities': {
136
+ browserName: null,
137
+ 'appium:options': {
138
+ automationName: 'UiAutomator2',
139
+ app: 'wikipedia-sample-app',// custom-id of the uploaded app
140
+ appPackage: 'org.wikipedia',
141
+ appActivity: 'org.wikipedia.main.MainActivity',
142
+ appWaitActivity: 'org.wikipedia.onboarding.InitialOnboardingActivity',
143
+ platformVersion: '11.0',
144
+ deviceName: 'Google Pixel 5'
145
+ },
146
+ appUploadUrl: 'https://raw.githubusercontent.com/priyansh3133/wikipedia/main/wikipedia.apk',// URL of the app to be uploaded to BrowserStack before starting the test
147
+ // appUploadPath: '/path/to/app_name.apk' // if the app needs to be uploaded to BrowserStack from a local system
148
+ }
149
+ },
150
+ 'browserstack.ios': {
151
+ extends: 'browserstack',
152
+ 'desiredCapabilities': {
153
+ browserName: null,
154
+ platformName: 'ios',
155
+ 'appium:options': {
156
+ automationName: 'XCUITest',
157
+ app: 'BStackSampleApp',
158
+ platformVersion: '16',
159
+ deviceName: 'iPhone 14'
160
+ },
161
+ appUploadUrl: 'https://www.browserstack.com/app-automate/sample-apps/ios/BStackSampleApp.ipa',
162
+ // appUploadPath: '/path/to/app_name.ipa'
163
+ }
164
+ ...
165
+ }
166
+ \`\`\``);
167
+ return combineInstructions(prerequisiteStep, envStep, installStep, configStep);
168
+ }
169
+ function getJestCommand(username, accessKey) {
170
+ const envStep = createStep("Set your BrowserStack credentials as environment variables:", `\`\`\`bash
171
+ export BROWSERSTACK_USERNAME=${username}
172
+ export BROWSERSTACK_ACCESS_KEY=${accessKey}
173
+ \`\`\``);
174
+ const installStep = createStep("Install Jest and BrowserStack SDK:", `\`\`\`bash
175
+ npm install --save-dev browserstack-node-sdk
176
+ \`\`\``);
177
+ return combineInstructions(envStep, installStep);
178
+ }
179
+ function getMochaCommand(username, accessKey) {
180
+ const envStep = createStep("Set your BrowserStack credentials as environment variables:", `\`\`\`bash
181
+ export BROWSERSTACK_USERNAME=${username}
182
+ export BROWSERSTACK_ACCESS_KEY=${accessKey}
183
+ \`\`\``);
184
+ const installStep = createStep("Install Mocha and BrowserStack SDK:", `\`\`\`bash
185
+ npm install --save-dev browserstack-node-sdk
186
+ \`\`\``);
187
+ return combineInstructions(envStep, installStep);
188
+ }
189
+ function getCucumberJSCommand(username, accessKey) {
190
+ return createStep("Set your BrowserStack credentials as environment variables:", `\`\`\`bash
191
+ export BROWSERSTACK_USERNAME=${username}
192
+ export BROWSERSTACK_ACCESS_KEY=${accessKey}
193
+ \`\`\``);
194
+ }
@@ -0,0 +1,3 @@
1
+ import { AppSDKSupportedTestingFramework } from "../index.js";
2
+ export declare function getPythonAppInstructions(testingFramework: AppSDKSupportedTestingFramework): string;
3
+ export declare function getPythonSDKCommand(framework: string, username: string, accessKey: string): string;
@@ -0,0 +1,76 @@
1
+ // Python instructions and commands for App SDK utilities
2
+ import { AppSDKSupportedTestingFrameworkEnum, createStep, createEnvStep, combineInstructions, PLATFORM_UTILS, } from "../index.js";
3
+ export function getPythonAppInstructions(testingFramework) {
4
+ switch (testingFramework) {
5
+ case AppSDKSupportedTestingFrameworkEnum.robot:
6
+ return createStep("Run your App Automate test suite with Robot Framework:", `\`\`\`bash
7
+ browserstack-sdk robot <path-to-test-files>
8
+ \`\`\``);
9
+ case AppSDKSupportedTestingFrameworkEnum.pytest:
10
+ return createStep("Run your App Automate test suite with Pytest:", `\`\`\`bash
11
+ browserstack-sdk pytest -s <file-name.py>
12
+ \`\`\``);
13
+ case AppSDKSupportedTestingFrameworkEnum.behave:
14
+ return createStep("Run your App Automate test suite with Behave:", `\`\`\`bash
15
+ browserstack-sdk behave <path-to-test-files>
16
+ \`\`\``);
17
+ case AppSDKSupportedTestingFrameworkEnum.lettuce:
18
+ return createStep("Run your test with Lettuce:", `\`\`\`bash
19
+ # Run using paver
20
+ paver run first_test
21
+ \`\`\``);
22
+ default:
23
+ return "";
24
+ }
25
+ }
26
+ export function getPythonSDKCommand(framework, username, accessKey) {
27
+ const { isWindows, getPlatformLabel } = PLATFORM_UTILS;
28
+ switch (framework) {
29
+ case "robot":
30
+ case "pytest":
31
+ case "behave":
32
+ return getPythonCommonSDKCommand(username, accessKey, isWindows, getPlatformLabel());
33
+ case "lettuce":
34
+ return getLettuceCommand(username, accessKey, isWindows, getPlatformLabel());
35
+ default:
36
+ return "";
37
+ }
38
+ }
39
+ function getPythonCommonSDKCommand(username, accessKey, isWindows, platformLabel) {
40
+ const envStep = createEnvStep(username, accessKey, isWindows, platformLabel, "Set your BrowserStack credentials as environment variables:");
41
+ const installStep = createStep("Install BrowserStack Python SDK:", `\`\`\`bash
42
+ python3 -m pip install browserstack-sdk
43
+ \`\`\``);
44
+ const setupStep = createStep("Set up BrowserStack SDK:", `\`\`\`bash
45
+ browserstack-sdk setup --username "${username}" --key "${accessKey}"
46
+ \`\`\``);
47
+ return combineInstructions(envStep, installStep, setupStep);
48
+ }
49
+ function getLettuceCommand(username, accessKey, isWindows, platformLabel) {
50
+ const envStep = createEnvStep(username, accessKey, isWindows, platformLabel, "Set your BrowserStack credentials as environment variables:");
51
+ const configStep = createStep("Configure Appium's desired capabilities in config.json:", `**Android example:**
52
+ \`\`\`json
53
+ {
54
+ "capabilities": {
55
+ "browserstack.user" : "${username}",
56
+ "browserstack.key" : "${accessKey}",
57
+ "project": "First Lettuce Android Project",
58
+ "build": "Lettuce Android",
59
+ "name": "first_test",
60
+ "browserstack.debug": true,
61
+ "app": "bs://<app-id>",
62
+ "device": "Google Pixel 3",
63
+ "os_version": "9.0"
64
+ }
65
+ }
66
+ \`\`\``);
67
+ const initStep = createStep("Initialize remote WebDriver in terrain.py:", `\`\`\`python
68
+ # Initialize the remote Webdriver using BrowserStack remote URL
69
+ # and desired capabilities defined above
70
+ context.browser = webdriver.Remote(
71
+ desired_capabilities=desired_capabilities,
72
+ command_executor="https://hub-cloud.browserstack.com/wd/hub"
73
+ )
74
+ \`\`\``);
75
+ return combineInstructions(envStep, configStep, initStep);
76
+ }
@@ -0,0 +1,2 @@
1
+ export declare function getRubyAppInstructions(): string;
2
+ export declare function getRubySDKCommand(framework: string, username: string, accessKey: string): string;
@@ -0,0 +1,85 @@
1
+ // Ruby instructions and commands for App SDK utilities
2
+ import { createStep, combineInstructions, createEnvStep, PLATFORM_UTILS, } from "../index.js";
3
+ const username = "${process.env.BROWSERSTACK_USERNAME}";
4
+ const accessKey = "${process.env.BROWSERSTACK_ACCESS_KEY}";
5
+ export function getRubyAppInstructions() {
6
+ const configStep = createStep("Create/Update the config file (config.yml) as follows:", `\`\`\`yaml
7
+ server: "hub-cloud.browserstack.com"
8
+
9
+ common_caps:
10
+ "browserstack.user": "${username}"
11
+ "browserstack.key": "${accessKey}"
12
+ "project": "First Cucumber Android Project"
13
+ "build": "Cucumber Android"
14
+ "browserstack.debug": true
15
+
16
+ browser_caps:
17
+ -
18
+ "deviceName": "Google Pixel 3"
19
+ "os_version": "9.0"
20
+ "app": "<replace with the APK path from the upload step>"
21
+ "name": "first_test"
22
+ \`\`\``);
23
+ const envStep = createStep("Create/Update your support/env.rb file:", `\`\`\`ruby
24
+ require 'rubygems'
25
+ require 'appium_lib'
26
+
27
+ # Load configuration from config.yml
28
+ caps = Appium.load_appium_txt file: File.expand_path('./../config.yml', __FILE__)
29
+ username = "${username}"
30
+ password = "${accessKey}"
31
+
32
+ # Create desired capabilities
33
+ desired_caps = {
34
+ caps: caps,
35
+ appium_lib: {
36
+ server_url: "https://#{username}:#{password}@#{caps['server']}/wd/hub"
37
+ }
38
+ }
39
+
40
+ # Initialize Appium driver
41
+ begin
42
+ $appium_driver = Appium::Driver.new(desired_caps, true)
43
+ $driver = $appium_driver.start_driver
44
+ rescue Exception => e
45
+ puts e.message
46
+ Process.exit(0)
47
+ end
48
+
49
+ # Add cleanup hook
50
+ at_exit do
51
+ $driver.quit if $driver
52
+ end
53
+ \`\`\``);
54
+ const runStep = createStep("Run the test:", `\`\`\`bash
55
+ bundle exec cucumber
56
+ \`\`\``);
57
+ return combineInstructions(configStep, envStep, runStep);
58
+ }
59
+ export function getRubySDKCommand(framework, username, accessKey) {
60
+ const { isWindows, getPlatformLabel } = PLATFORM_UTILS;
61
+ const envStep = createEnvStep(username, accessKey, isWindows, getPlatformLabel(), "Set your BrowserStack credentials as environment variables:");
62
+ const installStep = createStep("Install required Ruby gems:", `\`\`\`bash
63
+ # Install Bundler if not already installed
64
+ gem install bundler
65
+
66
+ # Install Appium Ruby client library
67
+ gem install appium_lib
68
+
69
+ # Install Cucumber
70
+ gem install cucumber
71
+ \`\`\``);
72
+ const gemfileStep = createStep("Create a Gemfile for dependency management:", `\`\`\`ruby
73
+ # Gemfile
74
+ source 'https://rubygems.org'
75
+
76
+ gem 'appium_lib'
77
+ gem 'cucumber'
78
+ \`\`\`
79
+
80
+ Then run:
81
+ \`\`\`bash
82
+ bundle install
83
+ \`\`\``);
84
+ return combineInstructions(envStep, installStep, gemfileStep);
85
+ }
@@ -0,0 +1,57 @@
1
+ export declare enum AppSDKSupportedLanguageEnum {
2
+ java = "java",
3
+ nodejs = "nodejs",
4
+ python = "python",
5
+ ruby = "ruby",
6
+ csharp = "csharp"
7
+ }
8
+ export type AppSDKSupportedLanguage = keyof typeof AppSDKSupportedLanguageEnum;
9
+ export declare enum AppSDKSupportedFrameworkEnum {
10
+ appium = "appium"
11
+ }
12
+ export type AppSDKSupportedFramework = keyof typeof AppSDKSupportedFrameworkEnum;
13
+ export declare enum AppSDKSupportedTestingFrameworkEnum {
14
+ testng = "testng",
15
+ junit5 = "junit5",
16
+ junit4 = "junit4",
17
+ selenide = "selenide",
18
+ jbehave = "jbehave",
19
+ cucumberTestng = "cucumberTestng",
20
+ cucumberJunit4 = "cucumberJunit4",
21
+ cucumberJunit5 = "cucumberJunit5",
22
+ webdriverio = "webdriverio",
23
+ nightwatch = "nightwatch",
24
+ jest = "jest",
25
+ mocha = "mocha",
26
+ cucumberJs = "cucumberJs",
27
+ robot = "robot",
28
+ pytest = "pytest",
29
+ behave = "behave",
30
+ lettuce = "lettuce",
31
+ rspec = "rspec",
32
+ cucumberRuby = "cucumberRuby",
33
+ nunit = "nunit",
34
+ mstest = "mstest",
35
+ xunit = "xunit",
36
+ specflow = "specflow",
37
+ reqnroll = "reqnroll"
38
+ }
39
+ export type AppSDKSupportedTestingFramework = keyof typeof AppSDKSupportedTestingFrameworkEnum;
40
+ export declare enum AppSDKSupportedPlatformEnum {
41
+ android = "android",
42
+ ios = "ios"
43
+ }
44
+ export type AppSDKSupportedPlatform = keyof typeof AppSDKSupportedPlatformEnum;
45
+ export interface AppSDKInstruction {
46
+ content: string;
47
+ type: "config" | "run" | "setup";
48
+ }
49
+ export declare const SUPPORTED_CONFIGURATIONS: {
50
+ appium: {
51
+ ruby: string[];
52
+ java: never[];
53
+ csharp: never[];
54
+ python: string[];
55
+ nodejs: string[];
56
+ };
57
+ };
@@ -0,0 +1,54 @@
1
+ // Shared types for App SDK utilities
2
+ export var AppSDKSupportedLanguageEnum;
3
+ (function (AppSDKSupportedLanguageEnum) {
4
+ AppSDKSupportedLanguageEnum["java"] = "java";
5
+ AppSDKSupportedLanguageEnum["nodejs"] = "nodejs";
6
+ AppSDKSupportedLanguageEnum["python"] = "python";
7
+ AppSDKSupportedLanguageEnum["ruby"] = "ruby";
8
+ AppSDKSupportedLanguageEnum["csharp"] = "csharp";
9
+ })(AppSDKSupportedLanguageEnum || (AppSDKSupportedLanguageEnum = {}));
10
+ export var AppSDKSupportedFrameworkEnum;
11
+ (function (AppSDKSupportedFrameworkEnum) {
12
+ AppSDKSupportedFrameworkEnum["appium"] = "appium";
13
+ })(AppSDKSupportedFrameworkEnum || (AppSDKSupportedFrameworkEnum = {}));
14
+ export var AppSDKSupportedTestingFrameworkEnum;
15
+ (function (AppSDKSupportedTestingFrameworkEnum) {
16
+ AppSDKSupportedTestingFrameworkEnum["testng"] = "testng";
17
+ AppSDKSupportedTestingFrameworkEnum["junit5"] = "junit5";
18
+ AppSDKSupportedTestingFrameworkEnum["junit4"] = "junit4";
19
+ AppSDKSupportedTestingFrameworkEnum["selenide"] = "selenide";
20
+ AppSDKSupportedTestingFrameworkEnum["jbehave"] = "jbehave";
21
+ AppSDKSupportedTestingFrameworkEnum["cucumberTestng"] = "cucumberTestng";
22
+ AppSDKSupportedTestingFrameworkEnum["cucumberJunit4"] = "cucumberJunit4";
23
+ AppSDKSupportedTestingFrameworkEnum["cucumberJunit5"] = "cucumberJunit5";
24
+ AppSDKSupportedTestingFrameworkEnum["webdriverio"] = "webdriverio";
25
+ AppSDKSupportedTestingFrameworkEnum["nightwatch"] = "nightwatch";
26
+ AppSDKSupportedTestingFrameworkEnum["jest"] = "jest";
27
+ AppSDKSupportedTestingFrameworkEnum["mocha"] = "mocha";
28
+ AppSDKSupportedTestingFrameworkEnum["cucumberJs"] = "cucumberJs";
29
+ AppSDKSupportedTestingFrameworkEnum["robot"] = "robot";
30
+ AppSDKSupportedTestingFrameworkEnum["pytest"] = "pytest";
31
+ AppSDKSupportedTestingFrameworkEnum["behave"] = "behave";
32
+ AppSDKSupportedTestingFrameworkEnum["lettuce"] = "lettuce";
33
+ AppSDKSupportedTestingFrameworkEnum["rspec"] = "rspec";
34
+ AppSDKSupportedTestingFrameworkEnum["cucumberRuby"] = "cucumberRuby";
35
+ AppSDKSupportedTestingFrameworkEnum["nunit"] = "nunit";
36
+ AppSDKSupportedTestingFrameworkEnum["mstest"] = "mstest";
37
+ AppSDKSupportedTestingFrameworkEnum["xunit"] = "xunit";
38
+ AppSDKSupportedTestingFrameworkEnum["specflow"] = "specflow";
39
+ AppSDKSupportedTestingFrameworkEnum["reqnroll"] = "reqnroll";
40
+ })(AppSDKSupportedTestingFrameworkEnum || (AppSDKSupportedTestingFrameworkEnum = {}));
41
+ export var AppSDKSupportedPlatformEnum;
42
+ (function (AppSDKSupportedPlatformEnum) {
43
+ AppSDKSupportedPlatformEnum["android"] = "android";
44
+ AppSDKSupportedPlatformEnum["ios"] = "ios";
45
+ })(AppSDKSupportedPlatformEnum || (AppSDKSupportedPlatformEnum = {}));
46
+ export const SUPPORTED_CONFIGURATIONS = {
47
+ appium: {
48
+ ruby: ["cucumberRuby"],
49
+ java: [],
50
+ csharp: [],
51
+ python: ["pytest", "robot", "behave", "lettuce"],
52
+ nodejs: ["jest", "mocha", "cucumberJs", "webdriverio", "nightwatch"],
53
+ },
54
+ };