@browserstack/mcp-server 1.2.2-beta.1 → 1.2.3

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 (88) hide show
  1. package/dist/lib/inmemory-store.d.ts +0 -1
  2. package/dist/lib/inmemory-store.js +0 -1
  3. package/dist/server-factory.js +0 -2
  4. package/dist/tools/bstack-sdk.d.ts +15 -2
  5. package/dist/tools/bstack-sdk.js +124 -7
  6. package/dist/tools/sdk-utils/{bstack/commands.d.ts → commands.d.ts} +1 -1
  7. package/dist/tools/sdk-utils/commands.js +65 -0
  8. package/dist/tools/sdk-utils/{bstack/frameworks.d.ts → constants.d.ts} +1 -1
  9. package/dist/tools/sdk-utils/{bstack/constants.js → constants.js} +78 -117
  10. package/dist/tools/sdk-utils/instructions.d.ts +6 -0
  11. package/dist/tools/sdk-utils/instructions.js +99 -0
  12. package/dist/tools/sdk-utils/percy/constants.d.ts +3 -0
  13. package/dist/tools/sdk-utils/{percy-bstack → percy}/constants.js +39 -13
  14. package/dist/tools/sdk-utils/percy/instructions.d.ts +10 -0
  15. package/dist/tools/sdk-utils/{percy-bstack → percy}/instructions.js +9 -5
  16. package/dist/tools/sdk-utils/percy/types.d.ts +5 -0
  17. package/package.json +1 -1
  18. package/dist/tools/add-percy-snapshots.d.ts +0 -5
  19. package/dist/tools/add-percy-snapshots.js +0 -17
  20. package/dist/tools/list-test-files.d.ts +0 -2
  21. package/dist/tools/list-test-files.js +0 -33
  22. package/dist/tools/percy-sdk.d.ts +0 -4
  23. package/dist/tools/percy-sdk.js +0 -88
  24. package/dist/tools/percy-snapshot-utils/constants.d.ts +0 -16
  25. package/dist/tools/percy-snapshot-utils/constants.js +0 -500
  26. package/dist/tools/percy-snapshot-utils/detect-test-files.d.ts +0 -10
  27. package/dist/tools/percy-snapshot-utils/detect-test-files.js +0 -194
  28. package/dist/tools/percy-snapshot-utils/types.d.ts +0 -15
  29. package/dist/tools/percy-snapshot-utils/utils.d.ts +0 -4
  30. package/dist/tools/percy-snapshot-utils/utils.js +0 -30
  31. package/dist/tools/sdk-utils/bstack/commands.js +0 -88
  32. package/dist/tools/sdk-utils/bstack/configUtils.d.ts +0 -4
  33. package/dist/tools/sdk-utils/bstack/configUtils.js +0 -66
  34. package/dist/tools/sdk-utils/bstack/constants.d.ts +0 -58
  35. package/dist/tools/sdk-utils/bstack/frameworks.js +0 -57
  36. package/dist/tools/sdk-utils/bstack/index.d.ts +0 -4
  37. package/dist/tools/sdk-utils/bstack/index.js +0 -5
  38. package/dist/tools/sdk-utils/bstack/sdkHandler.d.ts +0 -4
  39. package/dist/tools/sdk-utils/bstack/sdkHandler.js +0 -74
  40. package/dist/tools/sdk-utils/common/constants.d.ts +0 -10
  41. package/dist/tools/sdk-utils/common/constants.js +0 -86
  42. package/dist/tools/sdk-utils/common/formatUtils.d.ts +0 -5
  43. package/dist/tools/sdk-utils/common/formatUtils.js +0 -27
  44. package/dist/tools/sdk-utils/common/index.d.ts +0 -3
  45. package/dist/tools/sdk-utils/common/index.js +0 -4
  46. package/dist/tools/sdk-utils/common/instructionUtils.d.ts +0 -8
  47. package/dist/tools/sdk-utils/common/instructionUtils.js +0 -20
  48. package/dist/tools/sdk-utils/common/schema.d.ts +0 -61
  49. package/dist/tools/sdk-utils/common/schema.js +0 -28
  50. package/dist/tools/sdk-utils/common/types.d.ts +0 -66
  51. package/dist/tools/sdk-utils/common/types.js +0 -50
  52. package/dist/tools/sdk-utils/common/utils.d.ts +0 -25
  53. package/dist/tools/sdk-utils/common/utils.js +0 -84
  54. package/dist/tools/sdk-utils/handler.d.ts +0 -5
  55. package/dist/tools/sdk-utils/handler.js +0 -144
  56. package/dist/tools/sdk-utils/percy-automate/constants.d.ts +0 -11
  57. package/dist/tools/sdk-utils/percy-automate/constants.js +0 -365
  58. package/dist/tools/sdk-utils/percy-automate/frameworks.d.ts +0 -8
  59. package/dist/tools/sdk-utils/percy-automate/frameworks.js +0 -50
  60. package/dist/tools/sdk-utils/percy-automate/handler.d.ts +0 -3
  61. package/dist/tools/sdk-utils/percy-automate/handler.js +0 -30
  62. package/dist/tools/sdk-utils/percy-automate/index.d.ts +0 -1
  63. package/dist/tools/sdk-utils/percy-automate/index.js +0 -2
  64. package/dist/tools/sdk-utils/percy-automate/types.d.ts +0 -13
  65. package/dist/tools/sdk-utils/percy-automate/types.js +0 -1
  66. package/dist/tools/sdk-utils/percy-bstack/constants.d.ts +0 -4
  67. package/dist/tools/sdk-utils/percy-bstack/frameworks.d.ts +0 -2
  68. package/dist/tools/sdk-utils/percy-bstack/frameworks.js +0 -27
  69. package/dist/tools/sdk-utils/percy-bstack/handler.d.ts +0 -4
  70. package/dist/tools/sdk-utils/percy-bstack/handler.js +0 -99
  71. package/dist/tools/sdk-utils/percy-bstack/index.d.ts +0 -4
  72. package/dist/tools/sdk-utils/percy-bstack/index.js +0 -4
  73. package/dist/tools/sdk-utils/percy-bstack/instructions.d.ts +0 -7
  74. package/dist/tools/sdk-utils/percy-bstack/types.d.ts +0 -13
  75. package/dist/tools/sdk-utils/percy-bstack/types.js +0 -5
  76. package/dist/tools/sdk-utils/percy-web/constants.d.ts +0 -41
  77. package/dist/tools/sdk-utils/percy-web/constants.js +0 -941
  78. package/dist/tools/sdk-utils/percy-web/fetchPercyToken.d.ts +0 -4
  79. package/dist/tools/sdk-utils/percy-web/fetchPercyToken.js +0 -28
  80. package/dist/tools/sdk-utils/percy-web/frameworks.d.ts +0 -7
  81. package/dist/tools/sdk-utils/percy-web/frameworks.js +0 -103
  82. package/dist/tools/sdk-utils/percy-web/handler.d.ts +0 -4
  83. package/dist/tools/sdk-utils/percy-web/handler.js +0 -27
  84. package/dist/tools/sdk-utils/percy-web/index.d.ts +0 -4
  85. package/dist/tools/sdk-utils/percy-web/index.js +0 -4
  86. package/dist/tools/sdk-utils/percy-web/types.d.ts +0 -12
  87. package/dist/tools/sdk-utils/percy-web/types.js +0 -1
  88. /package/dist/tools/{percy-snapshot-utils → sdk-utils/percy}/types.js +0 -0
@@ -1,2 +1 @@
1
1
  export declare const signedUrlMap: Map<string, object>;
2
- export declare const testFilePathsMap: Map<string, string[]>;
@@ -1,2 +1 @@
1
1
  export const signedUrlMap = new Map();
2
- export const testFilePathsMap = new Map();
@@ -4,7 +4,6 @@ const require = createRequire(import.meta.url);
4
4
  const packageJson = require("../package.json");
5
5
  import logger from "./logger.js";
6
6
  import addSDKTools from "./tools/bstack-sdk.js";
7
- import addPercyTools from "./tools/percy-sdk.js";
8
7
  import addBrowserLiveTools from "./tools/live.js";
9
8
  import addAccessibilityTools from "./tools/accessibility.js";
10
9
  import addTestManagementTools from "./tools/testmanagement.js";
@@ -39,7 +38,6 @@ export class BrowserStackMcpServer {
39
38
  const toolAdders = [
40
39
  addAccessibilityTools,
41
40
  addSDKTools,
42
- addPercyTools,
43
41
  addAppLiveTools,
44
42
  addBrowserLiveTools,
45
43
  addTestManagementTools,
@@ -1,4 +1,17 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
+ import { SDKSupportedBrowserAutomationFramework, SDKSupportedLanguage, SDKSupportedTestingFramework } from "./sdk-utils/types.js";
2
4
  import { BrowserStackConfig } from "../lib/types.js";
3
- export declare function registerRunBrowserStackTestsTool(server: McpServer, config: BrowserStackConfig): Record<string, any>;
4
- export default registerRunBrowserStackTestsTool;
5
+ /**
6
+ * BrowserStack SDK hooks into your test framework to seamlessly run tests on BrowserStack.
7
+ * This tool gives instructions to setup a browserstack.yml file in the project root and installs the necessary dependencies.
8
+ */
9
+ export declare function bootstrapProjectWithSDK({ detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage, desiredPlatforms, enablePercy, config, }: {
10
+ detectedBrowserAutomationFramework: SDKSupportedBrowserAutomationFramework;
11
+ detectedTestingFramework: SDKSupportedTestingFramework;
12
+ detectedLanguage: SDKSupportedLanguage;
13
+ desiredPlatforms: string[];
14
+ enablePercy: boolean;
15
+ config: BrowserStackConfig;
16
+ }): Promise<CallToolResult>;
17
+ export default function addSDKTools(server: McpServer, config: BrowserStackConfig): Record<string, any>;
@@ -1,11 +1,128 @@
1
- import { RunTestsOnBrowserStackParamsShape } from "./sdk-utils/common/schema.js";
2
- import { runTestsOnBrowserStackHandler } from "./sdk-utils/handler.js";
3
- import { RUN_ON_BROWSERSTACK_DESCRIPTION } from "./sdk-utils/common/constants.js";
4
- export function registerRunBrowserStackTestsTool(server, config) {
1
+ import { z } from "zod";
2
+ import { trackMCP } from "../lib/instrumentation.js";
3
+ import { getSDKPrefixCommand } from "./sdk-utils/commands.js";
4
+ import { SDKSupportedLanguageEnum, SDKSupportedBrowserAutomationFrameworkEnum, SDKSupportedTestingFrameworkEnum, } from "./sdk-utils/types.js";
5
+ import { generateBrowserStackYMLInstructions, getInstructionsForProjectConfiguration, formatInstructionsWithNumbers, } from "./sdk-utils/instructions.js";
6
+ import { formatPercyInstructions, getPercyInstructions, } from "./sdk-utils/percy/instructions.js";
7
+ import { getBrowserStackAuth } from "../lib/get-auth.js";
8
+ /**
9
+ * BrowserStack SDK hooks into your test framework to seamlessly run tests on BrowserStack.
10
+ * This tool gives instructions to setup a browserstack.yml file in the project root and installs the necessary dependencies.
11
+ */
12
+ export async function bootstrapProjectWithSDK({ detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage, desiredPlatforms, enablePercy, config, }) {
13
+ // Get credentials from config
14
+ const authString = getBrowserStackAuth(config);
15
+ const [username, accessKey] = authString.split(":");
16
+ // Handle frameworks with unique setup instructions that don't use browserstack.yml
17
+ if (detectedBrowserAutomationFramework === "cypress" ||
18
+ detectedTestingFramework === "webdriverio") {
19
+ let combinedInstructions = getInstructionsForProjectConfiguration(detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage, username, accessKey);
20
+ if (enablePercy) {
21
+ const percyInstructions = getPercyInstructions(detectedLanguage, detectedBrowserAutomationFramework, detectedTestingFramework);
22
+ if (percyInstructions) {
23
+ combinedInstructions +=
24
+ "\n\n" + formatPercyInstructions(percyInstructions);
25
+ }
26
+ else {
27
+ throw new Error(`Percy is currently not supported through MCP for ${detectedLanguage} with ${detectedTestingFramework}. If you want to run the test cases without Percy, disable Percy and run it again.`);
28
+ }
29
+ }
30
+ // Apply consistent formatting for all configurations
31
+ return formatFinalInstructions(combinedInstructions);
32
+ }
33
+ // Handle default flow using browserstack.yml
34
+ const sdkSetupCommand = getSDKPrefixCommand(detectedLanguage, detectedTestingFramework, username, accessKey);
35
+ const ymlInstructions = generateBrowserStackYMLInstructions(desiredPlatforms, enablePercy);
36
+ const instructionsForProjectConfiguration = getInstructionsForProjectConfiguration(detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage, username, accessKey);
37
+ let combinedInstructions = "";
38
+ // Step 1: Add SDK setup command
39
+ if (sdkSetupCommand) {
40
+ combinedInstructions += sdkSetupCommand;
41
+ }
42
+ // Step 2: Add browserstack.yml setup
43
+ if (ymlInstructions) {
44
+ combinedInstructions += "\n\n---STEP---\n" + ymlInstructions;
45
+ }
46
+ // Step 3: Add language/framework-specific setup
47
+ if (instructionsForProjectConfiguration) {
48
+ combinedInstructions += "\n\n" + instructionsForProjectConfiguration;
49
+ }
50
+ // Step 4: Add Percy setup if applicable
51
+ if (enablePercy) {
52
+ const percyInstructions = getPercyInstructions(detectedLanguage, detectedBrowserAutomationFramework, detectedTestingFramework);
53
+ if (percyInstructions) {
54
+ combinedInstructions +=
55
+ "\n\n" + formatPercyInstructions(percyInstructions);
56
+ }
57
+ else {
58
+ throw new Error(`Percy is currently not supported through MCP for ${detectedLanguage} with ${detectedTestingFramework}. If you want to run the test cases without Percy, disable Percy and run it again.`);
59
+ }
60
+ }
61
+ // Apply consistent formatting for all configurations
62
+ return formatFinalInstructions(combinedInstructions);
63
+ }
64
+ // Helper function to apply consistent formatting to all instruction types
65
+ function formatFinalInstructions(combinedInstructions) {
66
+ const fullInstructions = `⚠️ IMPORTANT: DO NOT SKIP ANY STEP
67
+ All the setup steps described in this file MUST be executed regardless of any existing configuration or setup.
68
+ This ensures proper BrowserStack SDK setup.
69
+
70
+ ${formatInstructionsWithNumbers(combinedInstructions)}`;
71
+ return {
72
+ content: [
73
+ {
74
+ type: "text",
75
+ text: fullInstructions,
76
+ isError: false,
77
+ },
78
+ ],
79
+ };
80
+ }
81
+ export default function addSDKTools(server, config) {
5
82
  const tools = {};
6
- tools.setupBrowserStackAutomateTests = server.tool("setupBrowserStackAutomateTests", RUN_ON_BROWSERSTACK_DESCRIPTION, RunTestsOnBrowserStackParamsShape, async (args) => {
7
- return runTestsOnBrowserStackHandler(args, config);
83
+ tools.setupBrowserStackAutomateTests = server.tool("setupBrowserStackAutomateTests", "Set up and run automated web-based tests on BrowserStack using the BrowserStack SDK. Use for functional or integration tests on BrowserStack, with optional Percy visual testing for supported frameworks. Example prompts: run this test on browserstack; run this test on browserstack with Percy; set up this project for browserstack with Percy. Integrate BrowserStack SDK into your project", {
84
+ detectedBrowserAutomationFramework: z
85
+ .nativeEnum(SDKSupportedBrowserAutomationFrameworkEnum)
86
+ .describe("The automation framework configured in the project. Example: 'playwright', 'selenium'"),
87
+ detectedTestingFramework: z
88
+ .nativeEnum(SDKSupportedTestingFrameworkEnum)
89
+ .describe("The testing framework used in the project. Be precise with framework selection Example: 'webdriverio', 'jest', 'pytest', 'junit4', 'junit5', 'mocha'"),
90
+ detectedLanguage: z
91
+ .nativeEnum(SDKSupportedLanguageEnum)
92
+ .describe("The programming language used in the project. Example: 'nodejs', 'python', 'java', 'csharp'"),
93
+ desiredPlatforms: z
94
+ .array(z.enum(["windows", "macos", "android", "ios"]))
95
+ .describe("The platforms the user wants to test on. Always ask this to the user, do not try to infer this."),
96
+ enablePercy: z
97
+ .boolean()
98
+ .optional()
99
+ .default(false)
100
+ .describe("Set to true if the user wants to enable Percy for visual testing. Defaults to false."),
101
+ }, async (args) => {
102
+ try {
103
+ trackMCP("runTestsOnBrowserStack", server.server.getClientVersion(), undefined, config);
104
+ return await bootstrapProjectWithSDK({
105
+ detectedBrowserAutomationFramework: args.detectedBrowserAutomationFramework,
106
+ detectedTestingFramework: args.detectedTestingFramework,
107
+ detectedLanguage: args.detectedLanguage,
108
+ desiredPlatforms: args.desiredPlatforms,
109
+ enablePercy: args.enablePercy,
110
+ config,
111
+ });
112
+ }
113
+ catch (error) {
114
+ trackMCP("runTestsOnBrowserStack", server.server.getClientVersion(), error, config);
115
+ return {
116
+ content: [
117
+ {
118
+ type: "text",
119
+ text: `Failed to bootstrap project with BrowserStack SDK. Error: ${error}. Please open an issue on GitHub if the problem persists`,
120
+ isError: true,
121
+ },
122
+ ],
123
+ isError: true,
124
+ };
125
+ }
8
126
  });
9
127
  return tools;
10
128
  }
11
- export default registerRunBrowserStackTestsTool;
@@ -1,3 +1,3 @@
1
- import { SDKSupportedLanguage } from "../common/types.js";
1
+ import { SDKSupportedLanguage } from "./types.js";
2
2
  export declare function getSDKPrefixCommand(language: SDKSupportedLanguage, framework: string, username: string, accessKey: string): string;
3
3
  export declare function getJavaFrameworkForMaven(framework: string): string;
@@ -0,0 +1,65 @@
1
+ // Framework mapping for Java Maven archetype generation
2
+ const JAVA_FRAMEWORK_MAP = {
3
+ testng: "testng",
4
+ junit5: "junit5",
5
+ junit4: "junit4",
6
+ cucumber: "cucumber-testng",
7
+ serenity: "serenity",
8
+ };
9
+ // Common Gradle setup instructions (platform-independent)
10
+ const GRADLE_SETUP_INSTRUCTIONS = `
11
+ **For Gradle setup:**
12
+ 1. Add browserstack-java-sdk to dependencies:
13
+ compileOnly 'com.browserstack:browserstack-java-sdk:latest.release'
14
+
15
+ 2. Add browserstackSDK path variable:
16
+ def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
17
+
18
+ 3. Add javaagent to gradle tasks:
19
+ jvmArgs "-javaagent:\${browserstackSDKArtifact.file}"
20
+ `;
21
+ export function getSDKPrefixCommand(language, framework, username, accessKey) {
22
+ switch (language) {
23
+ case "nodejs":
24
+ return `---STEP---
25
+ Install BrowserStack Node SDK using command:
26
+ \`\`\`bash
27
+ npm i -D browserstack-node-sdk@latest
28
+ \`\`\`
29
+ ---STEP---
30
+ Run the following command to setup browserstack sdk:
31
+ \`\`\`bash
32
+ npx setup --username ${username} --key ${accessKey}
33
+ \`\`\`
34
+ ---STEP---
35
+ Edit the browserstack.yml file that was created in the project root to add your desired platforms and browsers.`;
36
+ case "java": {
37
+ const mavenFramework = getJavaFrameworkForMaven(framework);
38
+ const isWindows = process.platform === "win32";
39
+ const mavenCommand = isWindows
40
+ ? `mvn archetype:generate -B -DarchetypeGroupId="com.browserstack" -DarchetypeArtifactId="browserstack-sdk-archetype-integrate" -DarchetypeVersion="1.0" -DgroupId="com.browserstack" -DartifactId="browserstack-sdk-archetype-integrate" -Dversion="1.0" -DBROWSERSTACK_USERNAME="${process.env.BROWSERSTACK_USERNAME}" -DBROWSERSTACK_ACCESS_KEY="${process.env.BROWSERSTACK_ACCESS_KEY}" -DBROWSERSTACK_FRAMEWORK="${mavenFramework}"`
41
+ : `mvn archetype:generate -B -DarchetypeGroupId=com.browserstack \\
42
+ -DarchetypeArtifactId=browserstack-sdk-archetype-integrate -DarchetypeVersion=1.0 \\
43
+ -DgroupId=com.browserstack -DartifactId=browserstack-sdk-archetype-integrate -Dversion=1.0 \\
44
+ -DBROWSERSTACK_USERNAME="${username}" \\
45
+ -DBROWSERSTACK_ACCESS_KEY="${accessKey}" \\
46
+ -DBROWSERSTACK_FRAMEWORK="${mavenFramework}"`;
47
+ const platformLabel = isWindows ? "Windows" : "macOS/Linux";
48
+ return `---STEP---
49
+ Install BrowserStack Java SDK
50
+
51
+ **Maven command for ${framework} (${platformLabel}):**
52
+ Run the command, it is required to generate the browserstack-sdk-archetype-integrate project:
53
+ ${mavenCommand}
54
+
55
+ Alternative setup for Gradle users:
56
+ ${GRADLE_SETUP_INSTRUCTIONS}`;
57
+ }
58
+ // Add more languages as needed
59
+ default:
60
+ return "";
61
+ }
62
+ }
63
+ export function getJavaFrameworkForMaven(framework) {
64
+ return JAVA_FRAMEWORK_MAP[framework] || framework;
65
+ }
@@ -1,2 +1,2 @@
1
- import { ConfigMapping } from "../common/types.js";
1
+ import { ConfigMapping } from "./types.js";
2
2
  export declare const SUPPORTED_CONFIGURATIONS: ConfigMapping;
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * ---------- PYTHON INSTRUCTIONS ----------
3
3
  */
4
- export const pythonInstructions = (username, accessKey) => {
5
- const setup = `
4
+ const pythonInstructions = (username, accessKey) => `
6
5
  ---STEP---
7
6
 
8
7
  Install the BrowserStack SDK:
@@ -16,8 +15,7 @@ Setup the BrowserStack SDK with your credentials:
16
15
  \`\`\`bash
17
16
  browserstack-sdk setup --username "${username}" --key "${accessKey}"
18
17
  \`\`\`
19
- `;
20
- const run = `
18
+
21
19
  ---STEP---
22
20
 
23
21
  Run your tests on BrowserStack:
@@ -25,10 +23,7 @@ Run your tests on BrowserStack:
25
23
  browserstack-sdk python <path-to-test-file>
26
24
  \`\`\`
27
25
  `;
28
- return { setup, run };
29
- };
30
- export const generatePythonFrameworkInstructions = (framework) => (username, accessKey) => {
31
- const setup = `
26
+ const generatePythonFrameworkInstructions = (framework) => (username, accessKey) => `
32
27
  ---STEP---
33
28
 
34
29
  Install the BrowserStack SDK:
@@ -43,8 +38,7 @@ Setup the BrowserStack SDK with framework-specific configuration:
43
38
  \`\`\`bash
44
39
  browserstack-sdk setup --framework "${framework}" --username "${username}" --key "${accessKey}"
45
40
  \`\`\`
46
- `;
47
- const run = `
41
+
48
42
  ---STEP---
49
43
 
50
44
  Run your ${framework} tests on BrowserStack:
@@ -52,17 +46,14 @@ Run your ${framework} tests on BrowserStack:
52
46
  browserstack-sdk ${framework} <path-to-test-files>
53
47
  \`\`\`
54
48
  `;
55
- return { setup, run };
56
- };
57
- export const robotInstructions = generatePythonFrameworkInstructions("robot");
58
- export const behaveInstructions = generatePythonFrameworkInstructions("behave");
59
- export const pytestInstructions = generatePythonFrameworkInstructions("pytest");
49
+ const robotInstructions = generatePythonFrameworkInstructions("robot");
50
+ const behaveInstructions = generatePythonFrameworkInstructions("behave");
51
+ const pytestInstructions = generatePythonFrameworkInstructions("pytest");
60
52
  /**
61
53
  * ---------- JAVA INSTRUCTIONS ----------
62
54
  */
63
55
  const argsInstruction = '<argLine>-javaagent:"${com.browserstack:browserstack-java-sdk:jar}"</argLine>';
64
- export const javaInstructions = (username, accessKey) => {
65
- const setup = `
56
+ const javaInstructions = (username, accessKey) => `
66
57
  ---STEP---
67
58
 
68
59
  Add the BrowserStack Java SDK dependency to your \`pom.xml\`:
@@ -91,8 +82,7 @@ Export your BrowserStack credentials as environment variables:
91
82
  export BROWSERSTACK_USERNAME=${username}
92
83
  export BROWSERSTACK_ACCESS_KEY=${accessKey}
93
84
  \`\`\`
94
- `;
95
- const run = `
85
+
96
86
  ---STEP---
97
87
 
98
88
  Run your tests using Maven:
@@ -105,13 +95,66 @@ Or for Gradle:
105
95
  gradle clean test
106
96
  \`\`\`
107
97
  `;
108
- return { setup, run };
109
- };
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
+ `;
110
154
  /**
111
155
  * ---------- CSharp INSTRUCTIONS ----------
112
156
  */
113
- export const csharpCommonInstructions = (username, accessKey) => {
114
- const setup = `
157
+ const csharpCommonInstructions = (username, accessKey) => `
115
158
  ---STEP---
116
159
 
117
160
  Install BrowserStack TestAdapter NuGet package:
@@ -160,8 +203,7 @@ Install the x64 version of .NET for BrowserStack compatibility.
160
203
  sudo dotnet browserstack-sdk setup-dotnet --dotnet-path "<your-chosen-path>" --dotnet-version "<your-dotnet-version>"
161
204
  \`\`\`
162
205
  Common paths: /usr/local/share/dotnet, ~/dotnet-x64, or /opt/dotnet-x64
163
- `;
164
- const run = `
206
+
165
207
  ---STEP---
166
208
 
167
209
  Run the tests:
@@ -174,10 +216,7 @@ Run the tests:
174
216
  dotnet test
175
217
  \`\`\`
176
218
  `;
177
- return { setup, run };
178
- };
179
- export const csharpPlaywrightCommonInstructions = (username, accessKey) => {
180
- const setup = `
219
+ const csharpPlaywrightCommonInstructions = (username, accessKey) => `
181
220
  ---STEP---
182
221
 
183
222
  Install BrowserStack TestAdapter NuGet package:
@@ -239,8 +278,7 @@ Fix for Playwright architecture (macOS only):
239
278
  If the folder exists:
240
279
  \`<project-folder>/bin/Debug/net8.0/.playwright/node/darwin-arm64\`
241
280
  Rename \`darwin-arm64\` to \`darwin-x64\`
242
- `;
243
- const run = `
281
+
244
282
  ---STEP---
245
283
 
246
284
  Run the tests:
@@ -253,13 +291,10 @@ Run the tests:
253
291
  dotnet test
254
292
  \`\`\`
255
293
  `;
256
- return { setup, run };
257
- };
258
294
  /**
259
295
  * ---------- NODEJS INSTRUCTIONS ----------
260
296
  */
261
- export const nodejsInstructions = (username, accessKey) => {
262
- const setup = `
297
+ const nodejsInstructions = (username, accessKey) => `
263
298
  ---STEP---
264
299
 
265
300
  Ensure \`browserstack-node-sdk\` is present in package.json with the latest version:
@@ -295,21 +330,10 @@ export BROWSERSTACK_ACCESS_KEY=${accessKey}
295
330
  Run your tests:
296
331
  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.
297
332
  `;
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
- };
308
333
  /**
309
334
  * ---------- EXPORT CONFIG ----------
310
335
  */
311
- export const webdriverioInstructions = (username, accessKey) => {
312
- const setup = `
336
+ const webdriverioInstructions = (username, accessKey) => `
313
337
  ---STEP---
314
338
 
315
339
  Set BrowserStack Credentials:
@@ -408,17 +432,13 @@ exports.config.capabilities.forEach(function (caps) {
408
432
  caps[i] = { ...caps[i], ...exports.config.commonCapabilities[i]};
409
433
  });
410
434
  \`\`\`
411
- `;
412
- const run = `
435
+
413
436
  ---STEP---
414
437
 
415
438
  Run your tests:
416
439
  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.
417
440
  `;
418
- return { setup, run };
419
- };
420
- export const cypressInstructions = (username, accessKey) => {
421
- const setup = `
441
+ const cypressInstructions = (username, accessKey) => `
422
442
  ---STEP---
423
443
 
424
444
  Install the BrowserStack Cypress CLI:
@@ -479,8 +499,7 @@ Open the generated \`browserstack.json\` file and update it with your BrowserSta
479
499
  \`\`\`
480
500
 
481
501
  **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.
482
- `;
483
- const run = `
502
+
484
503
  ---STEP---
485
504
 
486
505
  Run Your Tests on BrowserStack:
@@ -489,69 +508,8 @@ Execute your tests on BrowserStack using the following command:
489
508
  npx browserstack-cypress run --sync
490
509
  \`\`\`
491
510
 
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
- \`\`\`
511
+ After the tests complete, you can view the results on your [BrowserStack Automate Dashboard](https://automate.browserstack.com/dashboard/).
536
512
  `;
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
- };
555
513
  export const SUPPORTED_CONFIGURATIONS = {
556
514
  python: {
557
515
  playwright: {
@@ -607,5 +565,8 @@ export const SUPPORTED_CONFIGURATIONS = {
607
565
  cypress: {
608
566
  cypress: { instructions: cypressInstructions },
609
567
  },
568
+ webdriverio: {
569
+ mocha: { instructions: webdriverioInstructions },
570
+ },
610
571
  },
611
572
  };
@@ -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;