@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.
- package/dist/lib/inmemory-store.d.ts +0 -1
- package/dist/lib/inmemory-store.js +0 -1
- package/dist/server-factory.js +0 -2
- package/dist/tools/bstack-sdk.d.ts +15 -2
- package/dist/tools/bstack-sdk.js +124 -7
- package/dist/tools/sdk-utils/{bstack/commands.d.ts → commands.d.ts} +1 -1
- package/dist/tools/sdk-utils/commands.js +65 -0
- package/dist/tools/sdk-utils/{bstack/frameworks.d.ts → constants.d.ts} +1 -1
- package/dist/tools/sdk-utils/{bstack/constants.js → constants.js} +78 -117
- package/dist/tools/sdk-utils/instructions.d.ts +6 -0
- package/dist/tools/sdk-utils/instructions.js +99 -0
- package/dist/tools/sdk-utils/percy/constants.d.ts +3 -0
- package/dist/tools/sdk-utils/{percy-bstack → percy}/constants.js +39 -13
- package/dist/tools/sdk-utils/percy/instructions.d.ts +10 -0
- package/dist/tools/sdk-utils/{percy-bstack → percy}/instructions.js +9 -5
- package/dist/tools/sdk-utils/percy/types.d.ts +5 -0
- package/package.json +1 -1
- package/dist/tools/add-percy-snapshots.d.ts +0 -5
- package/dist/tools/add-percy-snapshots.js +0 -17
- package/dist/tools/list-test-files.d.ts +0 -2
- package/dist/tools/list-test-files.js +0 -33
- package/dist/tools/percy-sdk.d.ts +0 -4
- package/dist/tools/percy-sdk.js +0 -88
- package/dist/tools/percy-snapshot-utils/constants.d.ts +0 -16
- package/dist/tools/percy-snapshot-utils/constants.js +0 -500
- package/dist/tools/percy-snapshot-utils/detect-test-files.d.ts +0 -10
- package/dist/tools/percy-snapshot-utils/detect-test-files.js +0 -194
- package/dist/tools/percy-snapshot-utils/types.d.ts +0 -15
- package/dist/tools/percy-snapshot-utils/utils.d.ts +0 -4
- package/dist/tools/percy-snapshot-utils/utils.js +0 -30
- package/dist/tools/sdk-utils/bstack/commands.js +0 -88
- package/dist/tools/sdk-utils/bstack/configUtils.d.ts +0 -4
- package/dist/tools/sdk-utils/bstack/configUtils.js +0 -66
- package/dist/tools/sdk-utils/bstack/constants.d.ts +0 -58
- package/dist/tools/sdk-utils/bstack/frameworks.js +0 -57
- package/dist/tools/sdk-utils/bstack/index.d.ts +0 -4
- package/dist/tools/sdk-utils/bstack/index.js +0 -5
- package/dist/tools/sdk-utils/bstack/sdkHandler.d.ts +0 -4
- package/dist/tools/sdk-utils/bstack/sdkHandler.js +0 -74
- package/dist/tools/sdk-utils/common/constants.d.ts +0 -10
- package/dist/tools/sdk-utils/common/constants.js +0 -86
- package/dist/tools/sdk-utils/common/formatUtils.d.ts +0 -5
- package/dist/tools/sdk-utils/common/formatUtils.js +0 -27
- package/dist/tools/sdk-utils/common/index.d.ts +0 -3
- package/dist/tools/sdk-utils/common/index.js +0 -4
- package/dist/tools/sdk-utils/common/instructionUtils.d.ts +0 -8
- package/dist/tools/sdk-utils/common/instructionUtils.js +0 -20
- package/dist/tools/sdk-utils/common/schema.d.ts +0 -61
- package/dist/tools/sdk-utils/common/schema.js +0 -28
- package/dist/tools/sdk-utils/common/types.d.ts +0 -66
- package/dist/tools/sdk-utils/common/types.js +0 -50
- package/dist/tools/sdk-utils/common/utils.d.ts +0 -25
- package/dist/tools/sdk-utils/common/utils.js +0 -84
- package/dist/tools/sdk-utils/handler.d.ts +0 -5
- package/dist/tools/sdk-utils/handler.js +0 -144
- package/dist/tools/sdk-utils/percy-automate/constants.d.ts +0 -11
- package/dist/tools/sdk-utils/percy-automate/constants.js +0 -365
- package/dist/tools/sdk-utils/percy-automate/frameworks.d.ts +0 -8
- package/dist/tools/sdk-utils/percy-automate/frameworks.js +0 -50
- package/dist/tools/sdk-utils/percy-automate/handler.d.ts +0 -3
- package/dist/tools/sdk-utils/percy-automate/handler.js +0 -30
- package/dist/tools/sdk-utils/percy-automate/index.d.ts +0 -1
- package/dist/tools/sdk-utils/percy-automate/index.js +0 -2
- package/dist/tools/sdk-utils/percy-automate/types.d.ts +0 -13
- package/dist/tools/sdk-utils/percy-automate/types.js +0 -1
- package/dist/tools/sdk-utils/percy-bstack/constants.d.ts +0 -4
- package/dist/tools/sdk-utils/percy-bstack/frameworks.d.ts +0 -2
- package/dist/tools/sdk-utils/percy-bstack/frameworks.js +0 -27
- package/dist/tools/sdk-utils/percy-bstack/handler.d.ts +0 -4
- package/dist/tools/sdk-utils/percy-bstack/handler.js +0 -99
- package/dist/tools/sdk-utils/percy-bstack/index.d.ts +0 -4
- package/dist/tools/sdk-utils/percy-bstack/index.js +0 -4
- package/dist/tools/sdk-utils/percy-bstack/instructions.d.ts +0 -7
- package/dist/tools/sdk-utils/percy-bstack/types.d.ts +0 -13
- package/dist/tools/sdk-utils/percy-bstack/types.js +0 -5
- package/dist/tools/sdk-utils/percy-web/constants.d.ts +0 -41
- package/dist/tools/sdk-utils/percy-web/constants.js +0 -941
- package/dist/tools/sdk-utils/percy-web/fetchPercyToken.d.ts +0 -4
- package/dist/tools/sdk-utils/percy-web/fetchPercyToken.js +0 -28
- package/dist/tools/sdk-utils/percy-web/frameworks.d.ts +0 -7
- package/dist/tools/sdk-utils/percy-web/frameworks.js +0 -103
- package/dist/tools/sdk-utils/percy-web/handler.d.ts +0 -4
- package/dist/tools/sdk-utils/percy-web/handler.js +0 -27
- package/dist/tools/sdk-utils/percy-web/index.d.ts +0 -4
- package/dist/tools/sdk-utils/percy-web/index.js +0 -4
- package/dist/tools/sdk-utils/percy-web/types.d.ts +0 -12
- package/dist/tools/sdk-utils/percy-web/types.js +0 -1
- /package/dist/tools/{percy-snapshot-utils → sdk-utils/percy}/types.js +0 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { SUPPORTED_CONFIGURATIONS } from "./constants.js";
|
|
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, username, accessKey) => {
|
|
4
|
+
const configuration = SUPPORTED_CONFIGURATIONS[detectedLanguage];
|
|
5
|
+
if (!configuration) {
|
|
6
|
+
throw new Error(`BrowserStack MCP Server currently does not support ${detectedLanguage}, ${errorMessageSuffix}`);
|
|
7
|
+
}
|
|
8
|
+
if (!configuration[detectedBrowserAutomationFramework]) {
|
|
9
|
+
throw new Error(`BrowserStack MCP Server currently does not support ${detectedBrowserAutomationFramework} for ${detectedLanguage}, ${errorMessageSuffix}`);
|
|
10
|
+
}
|
|
11
|
+
if (!configuration[detectedBrowserAutomationFramework][detectedTestingFramework]) {
|
|
12
|
+
throw new Error(`BrowserStack MCP Server currently does not support ${detectedTestingFramework} for ${detectedBrowserAutomationFramework} on ${detectedLanguage}, ${errorMessageSuffix}`);
|
|
13
|
+
}
|
|
14
|
+
const instructionFunction = configuration[detectedBrowserAutomationFramework][detectedTestingFramework]
|
|
15
|
+
.instructions;
|
|
16
|
+
return instructionFunction(username, accessKey);
|
|
17
|
+
};
|
|
18
|
+
export function generateBrowserStackYMLInstructions(desiredPlatforms, enablePercy = false) {
|
|
19
|
+
let ymlContent = `
|
|
20
|
+
# ======================
|
|
21
|
+
# BrowserStack Reporting
|
|
22
|
+
# ======================
|
|
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
|
|
27
|
+
|
|
28
|
+
# =======================================
|
|
29
|
+
# Platforms (Browsers / Devices to test)
|
|
30
|
+
# =======================================
|
|
31
|
+
# Platforms object contains all the browser / device combinations you want to test on.
|
|
32
|
+
# Generate this on the basis of the following platforms requested by the user:
|
|
33
|
+
# Requested platforms: ${desiredPlatforms}
|
|
34
|
+
platforms:
|
|
35
|
+
- os: Windows
|
|
36
|
+
osVersion: 11
|
|
37
|
+
browserName: chrome
|
|
38
|
+
browserVersion: latest
|
|
39
|
+
|
|
40
|
+
# =======================
|
|
41
|
+
# Parallels per Platform
|
|
42
|
+
# =======================
|
|
43
|
+
# The number of parallel threads to be used for each platform set.
|
|
44
|
+
# BrowserStack's SDK runner will select the best strategy based on the configured value
|
|
45
|
+
#
|
|
46
|
+
# Example 1 - If you have configured 3 platforms and set \`parallelsPerPlatform\` as 2, a total of 6 (2 * 3) parallel threads will be used on BrowserStack
|
|
47
|
+
#
|
|
48
|
+
# Example 2 - If you have configured 1 platform and set \`parallelsPerPlatform\` as 5, a total of 5 (1 * 5) parallel threads will be used on BrowserStack
|
|
49
|
+
parallelsPerPlatform: 1
|
|
50
|
+
|
|
51
|
+
# =================
|
|
52
|
+
# Local Testing
|
|
53
|
+
# =================
|
|
54
|
+
# Set to true to test local
|
|
55
|
+
browserstackLocal: true
|
|
56
|
+
|
|
57
|
+
# ===================
|
|
58
|
+
# Debugging features
|
|
59
|
+
# ===================
|
|
60
|
+
debug: true # Visual logs, text logs, etc.
|
|
61
|
+
testObservability: true # For Test Observability`;
|
|
62
|
+
if (enablePercy) {
|
|
63
|
+
ymlContent += `
|
|
64
|
+
|
|
65
|
+
# =====================
|
|
66
|
+
# Percy Visual Testing
|
|
67
|
+
# =====================
|
|
68
|
+
# Set percy to true to enable visual testing.
|
|
69
|
+
# Set percyCaptureMode to 'manual' to control when screenshots are taken.
|
|
70
|
+
percy: true
|
|
71
|
+
percyCaptureMode: manual`;
|
|
72
|
+
}
|
|
73
|
+
return `
|
|
74
|
+
Create a browserstack.yml file in the project root. The file should be in the following format:
|
|
75
|
+
|
|
76
|
+
\`\`\`yaml${ymlContent}
|
|
77
|
+
\`\`\`
|
|
78
|
+
\n`;
|
|
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;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export const javaSeleniumInstructions = `
|
|
1
|
+
const javaSeleniumInstructions = `
|
|
3
2
|
Import the BrowserStack Percy SDK in your test script:
|
|
4
3
|
Add the Percy import to your test file.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
---STEP---
|
|
7
6
|
|
|
8
7
|
Add screenshot capture method at required points:
|
|
9
8
|
Use the \`PercySDK.screenshot(driver, name)\` method at points in your test script where you want to capture screenshots.
|
|
@@ -33,8 +32,6 @@ export const nodejsSeleniumInstructions = `
|
|
|
33
32
|
Import the BrowserStack Percy SDK in your test script:
|
|
34
33
|
Add the Percy import to your test file.
|
|
35
34
|
|
|
36
|
-
${PERCY_SNAPSHOT_INSTRUCTION}
|
|
37
|
-
|
|
38
35
|
---STEP---
|
|
39
36
|
|
|
40
37
|
Add screenshot capture method at required points:
|
|
@@ -47,19 +44,19 @@ describe("sample Test", () => {
|
|
|
47
44
|
|
|
48
45
|
test("my test", async () => {
|
|
49
46
|
// ....
|
|
50
|
-
await percy.
|
|
47
|
+
await percy.snapshot(driver, "My Snapshot")
|
|
51
48
|
// ....
|
|
52
49
|
});
|
|
53
50
|
})
|
|
54
51
|
\`\`\`
|
|
55
52
|
`;
|
|
56
|
-
|
|
53
|
+
const webdriverioPercyInstructions = `
|
|
57
54
|
Enable Percy in \`wdio.conf.js\`:
|
|
58
55
|
In your WebdriverIO configuration file, modify the 'browserstack' service options to enable Percy.
|
|
59
56
|
|
|
60
57
|
- Set \`percy: true\`.
|
|
61
58
|
- Set a \`projectName\`. This is required and will be used for both your Automate and Percy projects.
|
|
62
|
-
- Set \`percyCaptureMode\`. The default \`
|
|
59
|
+
- Set \`percyCaptureMode\`. The default \`auto\` mode is recommended, which captures screenshots on events like clicks. Other modes are \`testcase\`, \`click\`, \`screenshot\`, and \`manual\`.
|
|
63
60
|
|
|
64
61
|
Here's how to modify the service configuration:
|
|
65
62
|
\`\`\`javascript
|
|
@@ -73,7 +70,7 @@ exports.config = {
|
|
|
73
70
|
{
|
|
74
71
|
// ... other service options
|
|
75
72
|
percy: true,
|
|
76
|
-
percyCaptureMode: '
|
|
73
|
+
percyCaptureMode: 'auto' // or 'manual', 'testcase', etc.
|
|
77
74
|
},
|
|
78
75
|
],
|
|
79
76
|
],
|
|
@@ -88,8 +85,6 @@ exports.config = {
|
|
|
88
85
|
};
|
|
89
86
|
\`\`\`
|
|
90
87
|
|
|
91
|
-
${PERCY_SNAPSHOT_INSTRUCTION}
|
|
92
|
-
|
|
93
88
|
---STEP---
|
|
94
89
|
|
|
95
90
|
Manually Capturing Screenshots (Optional):
|
|
@@ -117,11 +112,11 @@ describe("My WebdriverIO Test", () => {
|
|
|
117
112
|
});
|
|
118
113
|
\`\`\`
|
|
119
114
|
`;
|
|
120
|
-
|
|
115
|
+
const csharpSeleniumInstructions = `
|
|
121
116
|
Import the BrowserStack Percy SDK in your test script:
|
|
122
117
|
Add the Percy import to your test file.
|
|
123
118
|
|
|
124
|
-
|
|
119
|
+
---STEP---
|
|
125
120
|
|
|
126
121
|
Add screenshot capture method at required points:
|
|
127
122
|
Use the \`PercySDK.Screenshot(driver, name)\` method at points in your test script where you want to capture screenshots.
|
|
@@ -130,6 +125,8 @@ Here's an example:
|
|
|
130
125
|
|
|
131
126
|
\`\`\`csharp
|
|
132
127
|
using BrowserStackSDK.Percy;
|
|
128
|
+
using NUnit.Framework;
|
|
129
|
+
|
|
133
130
|
namespace Tests;
|
|
134
131
|
|
|
135
132
|
public class MyTest
|
|
@@ -149,3 +146,32 @@ public class MyTest
|
|
|
149
146
|
}
|
|
150
147
|
\`\`\`
|
|
151
148
|
`;
|
|
149
|
+
export const PERCY_INSTRUCTIONS = {
|
|
150
|
+
java: {
|
|
151
|
+
selenium: {
|
|
152
|
+
testng: { script_updates: javaSeleniumInstructions },
|
|
153
|
+
cucumber: { script_updates: javaSeleniumInstructions },
|
|
154
|
+
junit4: { script_updates: javaSeleniumInstructions },
|
|
155
|
+
junit5: { script_updates: javaSeleniumInstructions },
|
|
156
|
+
serenity: { script_updates: javaSeleniumInstructions },
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
csharp: {
|
|
160
|
+
selenium: {
|
|
161
|
+
nunit: { script_updates: csharpSeleniumInstructions },
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
nodejs: {
|
|
165
|
+
selenium: {
|
|
166
|
+
mocha: {
|
|
167
|
+
script_updates: nodejsSeleniumInstructions,
|
|
168
|
+
},
|
|
169
|
+
jest: {
|
|
170
|
+
script_updates: nodejsSeleniumInstructions,
|
|
171
|
+
},
|
|
172
|
+
webdriverio: {
|
|
173
|
+
script_updates: webdriverioPercyInstructions,
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SDKSupportedBrowserAutomationFramework, SDKSupportedLanguage, SDKSupportedTestingFramework } from "../types.js";
|
|
2
|
+
import { PercyInstructions } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves Percy-specific instructions for a given language and framework.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getPercyInstructions(language: SDKSupportedLanguage, automationFramework: SDKSupportedBrowserAutomationFramework, testingFramework: SDKSupportedTestingFramework): PercyInstructions | null;
|
|
7
|
+
/**
|
|
8
|
+
* Formats the retrieved Percy instructions into a user-friendly string.
|
|
9
|
+
*/
|
|
10
|
+
export declare function formatPercyInstructions(instructions: PercyInstructions): string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { PERCY_INSTRUCTIONS } from "./
|
|
2
|
-
|
|
1
|
+
import { PERCY_INSTRUCTIONS } from "./constants.js";
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves Percy-specific instructions for a given language and framework.
|
|
4
|
+
*/
|
|
3
5
|
export function getPercyInstructions(language, automationFramework, testingFramework) {
|
|
4
6
|
const langConfig = PERCY_INSTRUCTIONS[language];
|
|
5
7
|
if (!langConfig) {
|
|
@@ -15,10 +17,12 @@ export function getPercyInstructions(language, automationFramework, testingFrame
|
|
|
15
17
|
}
|
|
16
18
|
return percyInstructions;
|
|
17
19
|
}
|
|
18
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Formats the retrieved Percy instructions into a user-friendly string.
|
|
22
|
+
*/
|
|
19
23
|
export function formatPercyInstructions(instructions) {
|
|
20
|
-
return
|
|
24
|
+
return `\n\n## Percy Visual Testing Setup
|
|
21
25
|
To enable visual testing with Percy, you need to make the following changes to your project configuration and test scripts.
|
|
22
|
-
${instructions.
|
|
26
|
+
${instructions.script_updates}
|
|
23
27
|
`;
|
|
24
28
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SDKSupportedBrowserAutomationFramework, SDKSupportedLanguage, SDKSupportedTestingFramework } from "../types.js";
|
|
2
|
+
export interface PercyInstructions {
|
|
3
|
+
script_updates: string;
|
|
4
|
+
}
|
|
5
|
+
export type PercyConfigMapping = Partial<Record<SDKSupportedLanguage, Partial<Record<SDKSupportedBrowserAutomationFramework, Partial<Record<SDKSupportedTestingFramework, PercyInstructions>>>>>>;
|
package/package.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { testFilePathsMap } from "../lib/inmemory-store.js";
|
|
2
|
-
import { updateFileAndStep } from "./percy-snapshot-utils/utils.js";
|
|
3
|
-
import { percyWebSetupInstructions } from "../tools/sdk-utils/percy-web/handler.js";
|
|
4
|
-
export async function updateTestsWithPercyCommands(args) {
|
|
5
|
-
const { uuid, index } = args;
|
|
6
|
-
const filePaths = testFilePathsMap.get(uuid);
|
|
7
|
-
if (!filePaths) {
|
|
8
|
-
throw new Error(`No test files found in memory for UUID: ${uuid}`);
|
|
9
|
-
}
|
|
10
|
-
if (index < 0 || index >= filePaths.length) {
|
|
11
|
-
throw new Error(`Invalid index: ${index}. There are ${filePaths.length} files for UUID: ${uuid}`);
|
|
12
|
-
}
|
|
13
|
-
const result = await updateFileAndStep(filePaths[index], index, filePaths.length, percyWebSetupInstructions);
|
|
14
|
-
return {
|
|
15
|
-
content: result,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { listTestFiles } from "./percy-snapshot-utils/detect-test-files.js";
|
|
2
|
-
import { testFilePathsMap } from "../lib/inmemory-store.js";
|
|
3
|
-
import crypto from "crypto";
|
|
4
|
-
export async function addListTestFiles(args) {
|
|
5
|
-
const { dirs, language, framework } = args;
|
|
6
|
-
let testFiles = [];
|
|
7
|
-
for (const dir of dirs) {
|
|
8
|
-
const files = await listTestFiles({
|
|
9
|
-
language,
|
|
10
|
-
framework,
|
|
11
|
-
baseDir: dir,
|
|
12
|
-
});
|
|
13
|
-
testFiles = testFiles.concat(files);
|
|
14
|
-
}
|
|
15
|
-
if (testFiles.length === 0) {
|
|
16
|
-
throw new Error("No test files found");
|
|
17
|
-
}
|
|
18
|
-
// Generate a UUID and store the test files in memory
|
|
19
|
-
const uuid = crypto.randomUUID();
|
|
20
|
-
testFilePathsMap.set(uuid, testFiles);
|
|
21
|
-
return {
|
|
22
|
-
content: [
|
|
23
|
-
{
|
|
24
|
-
type: "text",
|
|
25
|
-
text: `The Test files are stored in memory with id ${uuid} and the total number of tests files found is ${testFiles.length}. You can use this UUID to retrieve the tests file paths later.`,
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
type: "text",
|
|
29
|
-
text: `You can now use the tool addPercySnapshotCommands to update the test file with Percy commands for visual testing with the UUID ${uuid}`,
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
};
|
|
33
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { BrowserStackConfig } from "../lib/types.js";
|
|
3
|
-
export declare function registerPercyTools(server: McpServer, config: BrowserStackConfig): Record<string, any>;
|
|
4
|
-
export default registerPercyTools;
|
package/dist/tools/percy-sdk.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { SetUpPercyParamsShape } from "./sdk-utils/common/schema.js";
|
|
2
|
-
import { updateTestsWithPercyCommands } from "./add-percy-snapshots.js";
|
|
3
|
-
import { addListTestFiles } from "./list-test-files.js";
|
|
4
|
-
import { trackMCP } from "../index.js";
|
|
5
|
-
import { setUpPercyHandler, setUpSimulatePercyChangeHandler, } from "./sdk-utils/handler.js";
|
|
6
|
-
import { SETUP_PERCY_DESCRIPTION, SIMULATE_PERCY_CHANGE_DESCRIPTION, LIST_TEST_FILES_DESCRIPTION, PERCY_SNAPSHOT_COMMANDS_DESCRIPTION, } from "./sdk-utils/common/constants.js";
|
|
7
|
-
import { ListTestFilesParamsShape, UpdateTestFileWithInstructionsParams, } from "./percy-snapshot-utils/constants.js";
|
|
8
|
-
export function registerPercyTools(server, config) {
|
|
9
|
-
const tools = {};
|
|
10
|
-
// Register setupPercyVisualTesting
|
|
11
|
-
tools.setupPercyVisualTesting = server.tool("setupPercyVisualTesting", SETUP_PERCY_DESCRIPTION, SetUpPercyParamsShape, async (args) => {
|
|
12
|
-
try {
|
|
13
|
-
trackMCP("setupPercyVisualTesting", server.server.getClientVersion(), config);
|
|
14
|
-
return setUpPercyHandler(args, config);
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
trackMCP("setupPercyVisualTesting", server.server.getClientVersion(), error, config);
|
|
18
|
-
return {
|
|
19
|
-
content: [
|
|
20
|
-
{
|
|
21
|
-
type: "text",
|
|
22
|
-
text: error instanceof Error ? error.message : String(error),
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
isError: true,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
// Register simulatePercyChange
|
|
30
|
-
tools.simulatePercyChange = server.tool("simulatePercyChange", SIMULATE_PERCY_CHANGE_DESCRIPTION, SetUpPercyParamsShape, async (args) => {
|
|
31
|
-
try {
|
|
32
|
-
trackMCP("simulatePercyChange", server.server.getClientVersion(), config);
|
|
33
|
-
return setUpSimulatePercyChangeHandler(args, config);
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
trackMCP("simulatePercyChange", server.server.getClientVersion(), error, config);
|
|
37
|
-
return {
|
|
38
|
-
content: [
|
|
39
|
-
{
|
|
40
|
-
type: "text",
|
|
41
|
-
text: error instanceof Error ? error.message : String(error),
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
isError: true,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
// Register addPercySnapshotCommands
|
|
49
|
-
tools.addPercySnapshotCommands = server.tool("addPercySnapshotCommands", PERCY_SNAPSHOT_COMMANDS_DESCRIPTION, UpdateTestFileWithInstructionsParams, async (args) => {
|
|
50
|
-
try {
|
|
51
|
-
trackMCP("addPercySnapshotCommands", server.server.getClientVersion(), config);
|
|
52
|
-
return await updateTestsWithPercyCommands(args);
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
trackMCP("addPercySnapshotCommands", server.server.getClientVersion(), error, config);
|
|
56
|
-
return {
|
|
57
|
-
content: [
|
|
58
|
-
{
|
|
59
|
-
type: "text",
|
|
60
|
-
text: error instanceof Error ? error.message : String(error),
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
isError: true,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
// Register listTestFiles
|
|
68
|
-
tools.listTestFiles = server.tool("listTestFiles", LIST_TEST_FILES_DESCRIPTION, ListTestFilesParamsShape, async (args) => {
|
|
69
|
-
try {
|
|
70
|
-
trackMCP("listTestFiles", server.server.getClientVersion(), config);
|
|
71
|
-
return addListTestFiles(args);
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
trackMCP("listTestFiles", server.server.getClientVersion(), error, config);
|
|
75
|
-
return {
|
|
76
|
-
content: [
|
|
77
|
-
{
|
|
78
|
-
type: "text",
|
|
79
|
-
text: error instanceof Error ? error.message : String(error),
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
isError: true,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
return tools;
|
|
87
|
-
}
|
|
88
|
-
export default registerPercyTools;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { SDKSupportedLanguage } from "../sdk-utils/common/types.js";
|
|
3
|
-
import { DetectionConfig } from "./types.js";
|
|
4
|
-
export declare const UpdateTestFileWithInstructionsParams: {
|
|
5
|
-
uuid: z.ZodString;
|
|
6
|
-
index: z.ZodNumber;
|
|
7
|
-
};
|
|
8
|
-
export declare const ListTestFilesParamsShape: {
|
|
9
|
-
dirs: z.ZodArray<z.ZodString, "many">;
|
|
10
|
-
language: z.ZodEnum<[string, ...string[]]>;
|
|
11
|
-
framework: z.ZodEnum<[string, ...string[]]>;
|
|
12
|
-
};
|
|
13
|
-
export declare const TEST_FILE_DETECTION: Record<SDKSupportedLanguage, DetectionConfig>;
|
|
14
|
-
export declare const EXCLUDED_DIRS: Set<string>;
|
|
15
|
-
export declare const backendIndicators: RegExp[];
|
|
16
|
-
export declare const strongUIIndicators: RegExp[];
|