@browserstack/mcp-server 1.2.1 → 1.2.2-beta.1
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/README.md +227 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/device-cache.d.ts +1 -0
- package/dist/lib/device-cache.js +28 -0
- package/dist/lib/inmemory-store.d.ts +1 -0
- package/dist/lib/inmemory-store.js +1 -0
- package/dist/lib/instrumentation.js +2 -0
- package/dist/oninitialized.js +4 -1
- package/dist/server-factory.js +3 -1
- package/dist/tools/accessibility.js +238 -78
- package/dist/tools/accessiblity-utils/auth-config.d.ts +39 -0
- package/dist/tools/accessiblity-utils/auth-config.js +125 -0
- package/dist/tools/accessiblity-utils/scanner.d.ts +1 -1
- package/dist/tools/accessiblity-utils/scanner.js +2 -1
- package/dist/tools/add-percy-snapshots.d.ts +5 -0
- package/dist/tools/add-percy-snapshots.js +17 -0
- package/dist/tools/appautomate-utils/appautomate.d.ts +2 -1
- package/dist/tools/appautomate-utils/appautomate.js +12 -9
- package/dist/tools/appautomate.js +56 -7
- package/dist/tools/applive-utils/start-session.d.ts +2 -1
- package/dist/tools/applive-utils/start-session.js +17 -6
- package/dist/tools/applive.d.ts +2 -1
- package/dist/tools/applive.js +21 -17
- package/dist/tools/bstack-sdk.d.ts +2 -15
- package/dist/tools/bstack-sdk.js +7 -124
- package/dist/tools/list-test-files.d.ts +2 -0
- package/dist/tools/list-test-files.js +33 -0
- package/dist/tools/percy-sdk.d.ts +4 -0
- package/dist/tools/percy-sdk.js +88 -0
- package/dist/tools/percy-snapshot-utils/constants.d.ts +16 -0
- package/dist/tools/percy-snapshot-utils/constants.js +500 -0
- package/dist/tools/percy-snapshot-utils/detect-test-files.d.ts +10 -0
- package/dist/tools/percy-snapshot-utils/detect-test-files.js +194 -0
- package/dist/tools/percy-snapshot-utils/types.d.ts +15 -0
- package/dist/tools/percy-snapshot-utils/utils.d.ts +4 -0
- package/dist/tools/percy-snapshot-utils/utils.js +30 -0
- package/dist/tools/sdk-utils/{commands.d.ts → bstack/commands.d.ts} +1 -1
- package/dist/tools/sdk-utils/bstack/commands.js +88 -0
- package/dist/tools/sdk-utils/bstack/configUtils.d.ts +4 -0
- package/dist/tools/sdk-utils/bstack/configUtils.js +66 -0
- package/dist/tools/sdk-utils/bstack/constants.d.ts +58 -0
- package/dist/tools/sdk-utils/{constants.js → bstack/constants.js} +128 -76
- package/dist/tools/sdk-utils/{constants.d.ts → bstack/frameworks.d.ts} +1 -1
- package/dist/tools/sdk-utils/bstack/frameworks.js +57 -0
- package/dist/tools/sdk-utils/bstack/index.d.ts +4 -0
- package/dist/tools/sdk-utils/bstack/index.js +5 -0
- package/dist/tools/sdk-utils/bstack/sdkHandler.d.ts +4 -0
- package/dist/tools/sdk-utils/bstack/sdkHandler.js +74 -0
- package/dist/tools/sdk-utils/common/constants.d.ts +10 -0
- package/dist/tools/sdk-utils/common/constants.js +86 -0
- package/dist/tools/sdk-utils/common/formatUtils.d.ts +5 -0
- package/dist/tools/sdk-utils/common/formatUtils.js +27 -0
- package/dist/tools/sdk-utils/common/index.d.ts +3 -0
- package/dist/tools/sdk-utils/common/index.js +4 -0
- package/dist/tools/sdk-utils/common/instructionUtils.d.ts +8 -0
- package/dist/tools/sdk-utils/common/instructionUtils.js +20 -0
- package/dist/tools/sdk-utils/common/schema.d.ts +61 -0
- package/dist/tools/sdk-utils/common/schema.js +28 -0
- package/dist/tools/sdk-utils/common/types.d.ts +66 -0
- package/dist/tools/sdk-utils/common/types.js +50 -0
- package/dist/tools/sdk-utils/common/utils.d.ts +25 -0
- package/dist/tools/sdk-utils/common/utils.js +84 -0
- package/dist/tools/sdk-utils/handler.d.ts +5 -0
- package/dist/tools/sdk-utils/handler.js +144 -0
- package/dist/tools/sdk-utils/percy-automate/constants.d.ts +11 -0
- package/dist/tools/sdk-utils/percy-automate/constants.js +365 -0
- package/dist/tools/sdk-utils/percy-automate/frameworks.d.ts +8 -0
- package/dist/tools/sdk-utils/percy-automate/frameworks.js +50 -0
- package/dist/tools/sdk-utils/percy-automate/handler.d.ts +3 -0
- package/dist/tools/sdk-utils/percy-automate/handler.js +30 -0
- package/dist/tools/sdk-utils/percy-automate/index.d.ts +1 -0
- package/dist/tools/sdk-utils/percy-automate/index.js +2 -0
- package/dist/tools/sdk-utils/percy-automate/types.d.ts +13 -0
- package/dist/tools/sdk-utils/percy-automate/types.js +1 -0
- package/dist/tools/sdk-utils/percy-bstack/constants.d.ts +4 -0
- package/dist/tools/sdk-utils/{percy → percy-bstack}/constants.js +13 -39
- package/dist/tools/sdk-utils/percy-bstack/frameworks.d.ts +2 -0
- package/dist/tools/sdk-utils/percy-bstack/frameworks.js +27 -0
- package/dist/tools/sdk-utils/percy-bstack/handler.d.ts +4 -0
- package/dist/tools/sdk-utils/percy-bstack/handler.js +99 -0
- package/dist/tools/sdk-utils/percy-bstack/index.d.ts +4 -0
- package/dist/tools/sdk-utils/percy-bstack/index.js +4 -0
- package/dist/tools/sdk-utils/percy-bstack/instructions.d.ts +7 -0
- package/dist/tools/sdk-utils/{percy → percy-bstack}/instructions.js +5 -9
- package/dist/tools/sdk-utils/percy-bstack/types.d.ts +13 -0
- package/dist/tools/sdk-utils/percy-bstack/types.js +5 -0
- package/dist/tools/sdk-utils/percy-web/constants.d.ts +41 -0
- package/dist/tools/sdk-utils/percy-web/constants.js +941 -0
- package/dist/tools/sdk-utils/percy-web/fetchPercyToken.d.ts +4 -0
- package/dist/tools/sdk-utils/percy-web/fetchPercyToken.js +28 -0
- package/dist/tools/sdk-utils/percy-web/frameworks.d.ts +7 -0
- package/dist/tools/sdk-utils/percy-web/frameworks.js +103 -0
- package/dist/tools/sdk-utils/percy-web/handler.d.ts +4 -0
- package/dist/tools/sdk-utils/percy-web/handler.js +27 -0
- package/dist/tools/sdk-utils/percy-web/index.d.ts +4 -0
- package/dist/tools/sdk-utils/percy-web/index.js +4 -0
- package/dist/tools/sdk-utils/percy-web/types.d.ts +12 -0
- package/dist/tools/sdk-utils/percy-web/types.js +1 -0
- package/dist/tools/sdk-utils/types.d.ts +2 -1
- package/dist/tools/sdk-utils/types.js +1 -0
- package/dist/tools/testmanagement-utils/create-testcase.d.ts +4 -0
- package/dist/tools/testmanagement-utils/create-testcase.js +6 -0
- package/package.json +1 -1
- package/dist/tools/sdk-utils/commands.js +0 -65
- package/dist/tools/sdk-utils/instructions.d.ts +0 -6
- package/dist/tools/sdk-utils/instructions.js +0 -99
- package/dist/tools/sdk-utils/percy/constants.d.ts +0 -3
- package/dist/tools/sdk-utils/percy/instructions.d.ts +0 -10
- package/dist/tools/sdk-utils/percy/types.d.ts +0 -5
- /package/dist/tools/{getFailureLogs.d.ts → get-failure-logs.d.ts} +0 -0
- /package/dist/tools/{getFailureLogs.js → get-failure-logs.js} +0 -0
- /package/dist/tools/{sdk-utils/percy → percy-snapshot-utils}/types.js +0 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { SetUpPercySchema, RunTestsOnBrowserStackSchema, } from "./common/schema.js";
|
|
2
|
+
import { getBootstrapFailedMessage, percyUnsupportedResult, } from "./common/utils.js";
|
|
3
|
+
import { formatToolResult } from "./common/utils.js";
|
|
4
|
+
import { PercyIntegrationTypeEnum } from "./common/types.js";
|
|
5
|
+
import { getBrowserStackAuth } from "../../lib/get-auth.js";
|
|
6
|
+
import { fetchPercyToken } from "./percy-web/fetchPercyToken.js";
|
|
7
|
+
import { runPercyWeb } from "./percy-web/handler.js";
|
|
8
|
+
import { runPercyAutomateOnly } from "./percy-automate/handler.js";
|
|
9
|
+
import { runBstackSDKOnly } from "./bstack/sdkHandler.js";
|
|
10
|
+
import { runPercyWithBrowserstackSDK } from "./percy-bstack/handler.js";
|
|
11
|
+
import { checkPercyIntegrationSupport } from "./common/utils.js";
|
|
12
|
+
import { PERCY_SIMULATE_INSTRUCTION, PERCY_REPLACE_REGEX, PERCY_SIMULATION_DRIVER_INSTRUCTION, } from "./common/constants.js";
|
|
13
|
+
export async function runTestsOnBrowserStackHandler(rawInput, config) {
|
|
14
|
+
try {
|
|
15
|
+
const input = RunTestsOnBrowserStackSchema.parse(rawInput);
|
|
16
|
+
// Only handle BrowserStack SDK setup for functional/integration tests.
|
|
17
|
+
const result = runBstackSDKOnly(input, config);
|
|
18
|
+
return await formatToolResult(result);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
throw new Error(getBootstrapFailedMessage(error, { config }));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export async function setUpPercyHandler(rawInput, config) {
|
|
25
|
+
try {
|
|
26
|
+
const input = SetUpPercySchema.parse(rawInput);
|
|
27
|
+
const authorization = getBrowserStackAuth(config);
|
|
28
|
+
const percyInput = {
|
|
29
|
+
projectName: input.projectName,
|
|
30
|
+
detectedLanguage: input.detectedLanguage,
|
|
31
|
+
detectedBrowserAutomationFramework: input.detectedBrowserAutomationFramework,
|
|
32
|
+
detectedTestingFramework: input.detectedTestingFramework,
|
|
33
|
+
integrationType: input.integrationType,
|
|
34
|
+
folderPaths: input.folderPaths || [],
|
|
35
|
+
};
|
|
36
|
+
// Check for Percy Web integration support
|
|
37
|
+
if (input.integrationType === PercyIntegrationTypeEnum.WEB) {
|
|
38
|
+
const supportCheck = checkPercyIntegrationSupport(percyInput);
|
|
39
|
+
if (!supportCheck.supported) {
|
|
40
|
+
return percyUnsupportedResult(PercyIntegrationTypeEnum.WEB, supportCheck);
|
|
41
|
+
}
|
|
42
|
+
// Fetch the Percy token
|
|
43
|
+
const percyToken = await fetchPercyToken(input.projectName, authorization, { type: PercyIntegrationTypeEnum.WEB });
|
|
44
|
+
const result = runPercyWeb(percyInput, percyToken);
|
|
45
|
+
return await formatToolResult(result);
|
|
46
|
+
}
|
|
47
|
+
else if (input.integrationType === PercyIntegrationTypeEnum.AUTOMATE) {
|
|
48
|
+
// First try Percy with BrowserStack SDK
|
|
49
|
+
const percyWithBrowserstackSDKResult = runPercyWithBrowserstackSDK({
|
|
50
|
+
...percyInput,
|
|
51
|
+
desiredPlatforms: [],
|
|
52
|
+
}, config);
|
|
53
|
+
const hasPercySDKError = percyWithBrowserstackSDKResult.steps &&
|
|
54
|
+
percyWithBrowserstackSDKResult.steps.some((step) => step.isError);
|
|
55
|
+
if (!hasPercySDKError) {
|
|
56
|
+
// Percy with SDK is supported, prepend warning and return those steps
|
|
57
|
+
if (percyWithBrowserstackSDKResult.steps) {
|
|
58
|
+
percyWithBrowserstackSDKResult.steps.unshift({
|
|
59
|
+
type: "instruction",
|
|
60
|
+
title: "Important: Existing SDK Setup",
|
|
61
|
+
content: "If you have already set up the BrowserStack SDK, do not override it unless you have explicitly decided to do so.",
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return await formatToolResult(percyWithBrowserstackSDKResult);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Fallback to standalone Percy Automate if supported
|
|
68
|
+
const supportCheck = checkPercyIntegrationSupport({
|
|
69
|
+
...percyInput,
|
|
70
|
+
integrationType: PercyIntegrationTypeEnum.AUTOMATE,
|
|
71
|
+
});
|
|
72
|
+
if (!supportCheck.supported) {
|
|
73
|
+
return percyUnsupportedResult(PercyIntegrationTypeEnum.AUTOMATE, supportCheck);
|
|
74
|
+
}
|
|
75
|
+
// SDK setup instructions (for Automate, without Percy)
|
|
76
|
+
const sdkInput = {
|
|
77
|
+
projectName: input.projectName,
|
|
78
|
+
detectedLanguage: input.detectedLanguage,
|
|
79
|
+
detectedBrowserAutomationFramework: input.detectedBrowserAutomationFramework,
|
|
80
|
+
detectedTestingFramework: input.detectedTestingFramework,
|
|
81
|
+
desiredPlatforms: [],
|
|
82
|
+
};
|
|
83
|
+
const sdkResult = runBstackSDKOnly(sdkInput, config, true);
|
|
84
|
+
// Percy Automate instructions
|
|
85
|
+
const percyToken = await fetchPercyToken(input.projectName, authorization, { type: PercyIntegrationTypeEnum.AUTOMATE });
|
|
86
|
+
const percyAutomateResult = runPercyAutomateOnly(percyInput, percyToken);
|
|
87
|
+
// Combine steps: warning, SDK steps, Percy Automate steps
|
|
88
|
+
const steps = [
|
|
89
|
+
{
|
|
90
|
+
type: "instruction",
|
|
91
|
+
title: "Important: Existing SDK Setup",
|
|
92
|
+
content: "If you have already set up the BrowserStack SDK, do not override it unless you have explicitly decided to do so.",
|
|
93
|
+
},
|
|
94
|
+
...(sdkResult.steps || []),
|
|
95
|
+
...(percyAutomateResult.steps || []),
|
|
96
|
+
];
|
|
97
|
+
// Combine all steps into the final result
|
|
98
|
+
return await formatToolResult({
|
|
99
|
+
...percyAutomateResult,
|
|
100
|
+
steps,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return {
|
|
106
|
+
content: [
|
|
107
|
+
{
|
|
108
|
+
type: "text",
|
|
109
|
+
text: "Unknown or unsupported Percy integration type requested.",
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
isError: true,
|
|
113
|
+
shouldSkipFormatting: true,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
throw new Error(getBootstrapFailedMessage(error, { config }));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export async function setUpSimulatePercyChangeHandler(rawInput, config) {
|
|
122
|
+
try {
|
|
123
|
+
const percyInstruction = await setUpPercyHandler(rawInput, config);
|
|
124
|
+
if (percyInstruction.isError) {
|
|
125
|
+
return percyInstruction;
|
|
126
|
+
}
|
|
127
|
+
if (Array.isArray(percyInstruction.content)) {
|
|
128
|
+
percyInstruction.content.forEach((item) => {
|
|
129
|
+
if (typeof item.text === "string" &&
|
|
130
|
+
PERCY_REPLACE_REGEX.test(item.text)) {
|
|
131
|
+
item.text = item.text.replace(PERCY_REPLACE_REGEX, PERCY_SIMULATE_INSTRUCTION);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
percyInstruction.content?.push({
|
|
136
|
+
type: "text",
|
|
137
|
+
text: PERCY_SIMULATION_DRIVER_INSTRUCTION,
|
|
138
|
+
});
|
|
139
|
+
return percyInstruction;
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
throw new Error(getBootstrapFailedMessage(error, { config }));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const percyAutomateReviewSnapshotsStep = "\n---STEP---\nReview the snapshots\n - Go to your Percy project on https://percy.io to review snapshots and approve/reject any visual changes.\n";
|
|
2
|
+
export declare const pythonPytestSeleniumInstructions = "\nInstall Percy Automate dependencies\n - Install Percy CLI:\n npm install --save-dev @percy/cli\n - Install Percy Python SDK for Automate:\n pip install percy-selenium\n\n---STEP---\nUpdate your Pytest test script \n\nInvoke listTestFiles() with the provided directories from user to gather all test files in memory and obtain the generated UUID ---STEP---\nProcess files in STRICT sequential order using tool addPercySnapshotCommands() with below instructions:\n- Start with index 0\n- Then index 1 \n- Then index 2\n- Continue sequentially until the last index\n- DO NOT skip any index numbers\n- DO NOT jump to random indices like 10, 20, 30\n- DO NOT worry about time consuming and any constraints.\n- DO NOT STOP until you add commands in all the files or you reach end of the files.\n\n - Import the Percy snapshot helper:\n from percy import percy_screenshot\n - In your test, take snapshots at key points:\n percy_screenshot(driver, \"Your snapshot name\")\n\nExample:\n```python\nimport pytest\nfrom selenium import webdriver\nfrom percy import percy_screenshot\n\n@pytest.fixture\ndef driver():\n driver = webdriver.Chrome()\n yield driver\n driver.quit()\n\ndef test_homepage(driver):\n driver.get(\"http://localhost:8000\")\n percy_screenshot(driver, \"Home page\")\n # ... more test steps ...\n percy_screenshot(driver, \"After login\")\n```\n\n---STEP---\nRun Percy Automate with your tests\n - Use the following command:\n npx percy exec -- browserstack-sdk pytest\n\n\n---STEP---\nReview the snapshots\n - Go to your Percy project on https://percy.io to review snapshots and approve/reject any visual changes.\n\n";
|
|
3
|
+
export declare const pythonPytestPlaywrightInstructions = "\nInstall Percy Automate dependencies\n - Install Percy CLI:\n npm install --save @percy/cli\n - Install Percy Playwright SDK for Automate:\n pip install percy-playwright\n\n---STEP---\nUpdate your Playwright test script\n\nInvoke listTestFiles() with the provided directories from user to gather all test files in memory and obtain the generated UUID ---STEP---\nProcess files in STRICT sequential order using tool addPercySnapshotCommands() with below instructions:\n- Start with index 0\n- Then index 1 \n- Then index 2\n- Continue sequentially until the last index\n- DO NOT skip any index numbers\n- DO NOT jump to random indices like 10, 20, 30\n- DO NOT worry about time consuming and any constraints.\n- DO NOT STOP until you add commands in all the files or you reach end of the files.\n\n - Import the Percy screenshot helper:\n from percy import percy_screenshot\n - In your test, take snapshots at key points:\n percy_screenshot(page, name=\"Your snapshot name\")\n # You can pass `options`:\n percy_screenshot(page, name=\"Your snapshot name\", options={ \"full_page\": True })\n\nExample:\n```python\nfrom playwright.sync_api import sync_playwright\nfrom percy import percy_screenshot\n\ndef test_visual_regression():\n with sync_playwright() as p:\n browser = p.chromium.launch()\n page = browser.new_page()\n page.goto(\"http://localhost:8000\")\n percy_screenshot(page, name=\"Home page\")\n # ... more test steps ...\n percy_screenshot(page, name=\"After login\", options={ \"full_page\": True })\n browser.close()\n```\n\n---STEP---\nRun Percy Automate with your tests\n - Use the following command:\n npx percy exec -- <command to run the automate script file>\n\n\n---STEP---\nReview the snapshots\n - Go to your Percy project on https://percy.io to review snapshots and approve/reject any visual changes.\n\n";
|
|
4
|
+
export declare const jsCypressPercyAutomateInstructions = "\nInstall Percy Automate dependencies\n - Install Percy CLI:\n npm install --save-dev @percy/cli\n - Install Percy Cypress SDK:\n npm install --save-dev @percy/cypress\n\n---STEP---\nUpdate your Cypress test script\n\nInvoke listTestFiles() with the provided directories from user to gather all test files in memory and obtain the generated UUID ---STEP---\nProcess files in STRICT sequential order using tool addPercySnapshotCommands() with below instructions:\n- Start with index 0\n- Then index 1 \n- Then index 2\n- Continue sequentially until the last index\n- DO NOT skip any index numbers\n- DO NOT jump to random indices like 10, 20, 30\n- DO NOT worry about time consuming and any constraints.\n- DO NOT STOP until you add commands in all the files or you reach end of the files.\n\n - Import and initialize Percy in your cypress/support/index.js:\n import '@percy/cypress';\n - In your test, take snapshots at key points:\n cy.percySnapshot('Your snapshot name');\n\nExample:\n```javascript\ndescribe('Percy Automate Cypress Example', () => {\n it('should take Percy snapshots', () => {\n cy.visit('http://localhost:8000');\n cy.percySnapshot('Home page');\n // ... more test steps ...\n cy.percySnapshot('After login');\n });\n});\n``` \n\n---STEP---\nRun Percy Automate with your tests\n - Use the following command:\n npx percy exec -- cypress run\n\n\n---STEP---\nReview the snapshots\n - Go to your Percy project on https://percy.io to review snapshots and approve/reject any visual changes.\n\n";
|
|
5
|
+
export declare const mochaPercyAutomateInstructions = "\nInstall Percy Automate dependencies\n - Install Percy CLI:\n npm install --save @percy/cli\n - Install Percy Selenium SDK:\n npm install @percy/selenium-webdriver@2.0.1\n\n---STEP---\nUpdate your Mocha Automate test script\n - Import the Percy screenshot helper:\n const { percyScreenshot } = require('@percy/selenium-webdriver');\n - Use the Percy screenshot command to take required screenshots in your Automate session:\n await percyScreenshot(driver, 'Screenshot 1');\n options = { percyCSS: 'h1{color:red;}' };\n await percyScreenshot(driver, 'Screenshot 2', options);\n\n---STEP---\nRun Percy Automate with your tests\n - Use the following command:\n npx percy exec -- <command to run the automate script file>\n\n\n---STEP---\nReview the snapshots\n - Go to your Percy project on https://percy.io to review snapshots and approve/reject any visual changes.\n\n";
|
|
6
|
+
export declare const mochaPercyPlaywrightInstructions = "\nInstall Percy Automate dependencies\n - Install the latest Percy CLI:\n npm install --save @percy/cli\n - Install the Percy Playwright SDK:\n npm install @percy/playwright\n\n---STEP---\nUpdate your Mocha Playwright test script\n - Import the Percy screenshot helper:\n const { percyScreenshot } = require(\"@percy/playwright\");\n - Use the Percy screenshot command to take required screenshots in your Automate session.\n\nExample:\n```javascript\nconst { percyScreenshot } = require(\"@percy/playwright\");\nawait percyScreenshot(page, \"Screenshot 1\");\n// With options\nawait percyScreenshot(page, \"Screenshot 2\", { percyCSS: \"h1{color:green;}\" });\n```\n\n---STEP---\nRun Percy Automate with your tests\n - Use the following command:\n npx percy exec -- <command to run the automate script file>\n\n\n---STEP---\nReview the snapshots\n - Go to your Percy project on https://percy.io to review snapshots and approve/reject any visual changes.\n\n";
|
|
7
|
+
export declare const jestPercyAutomateInstructions = "\nInstall or upgrade the BrowserStack SDK:\n - Install the SDK:\n npm i -D browserstack-node-sdk@latest\n - Run the setup:\n npx setup --username \"YOUR_USERNAME\" --key \"YOUR_ACCESS_KEY\"\n\n---STEP---\nManually capture screenshots:\n 1. Import the BrowserStack Percy SDK in your test script:\n const { percy } = require('browserstack-node-sdk');\n 2. Use `percy.screenshot(driver, name)` at desired points in your test.\n\nExample:\n```javascript\nconst { percy } = require('browserstack-node-sdk');\ndescribe(\"JestJS test\", () => {\n let driver;\n const caps = require(\"../\" + conf_file).capabilities;\n\n beforeAll(() => {\n driver = new Builder()\n .usingServer(\"http://example-servername/hub\")\n .withCapabilities(caps)\n .build();\n });\n\n test(\"my test\", async () => {\n // ...\n await percy.screenshot(driver, \"My Screenshot\");\n // ...\n });\n});\n```\n\n---STEP---\nRun your test script:\n - Use the following command:\n npm run [your-test-script-name]-browserstack\n\n\n---STEP---\nReview the snapshots\n - Go to your Percy project on https://percy.io to review snapshots and approve/reject any visual changes.\n\n";
|
|
8
|
+
export declare const webdriverioPercyAutomateInstructions = "\nInstall or upgrade BrowserStack SDK\n - Install the BrowserStack SDK:\n npm i -D @wdio/browserstack-service\n\n---STEP---\nUpdate your WebdriverIO config file\n 1. Set `percy: true`\n 2. Set a `projectName`\n 3. Set `percyCaptureMode: auto` (or another mode as needed)\n\nExample WebdriverIO config:\n```js\nexports.config = {\n user: process.env.BROWSERSTACK_USERNAME || 'YOUR_USERNAME',\n key: process.env.BROWSERSTACK_ACCESS_KEY || 'YOUR_ACCESS_KEY',\n hostname: 'hub.browserstack.com',\n services: [\n [\n 'browserstack',\n { browserstackLocal: true, opts: { forcelocal: false }, percy: true, percyCaptureMode: 'auto' }\n ],\n ],\n // add path to the test file\n}\n```\n\n---STEP---\n(Optional) Manually capture screenshots\n 1. Import the BrowserStack Percy SDK in your test script:\n const { percy } = require('browserstack-node-sdk');\n 2. Add the `await percy.screenshot(driver, name)` method at required points in your test script.\n\nExample:\n```javascript\n const { percy } = require('browserstack-node-sdk');\n 2. Add the `await percy.screenshot(driver, name)` method at required points in your test script.\n\nExample:\n```javascript\nconst { percy } = require('browserstack-node-sdk');\ndescribe(\"WebdriverIO Test\", () => {\n it(\"my test\", async () => {\n // ....\n await percy.screenshot(driver, \"My Screenshot\")\n // ....\n });\n});\n```\n\n---STEP---\nRun your test script\n - Use the commands defined in your package.json file to run the tests on BrowserStack.\n\n\n---STEP---\nReview the snapshots\n - Go to your Percy project on https://percy.io to review snapshots and approve/reject any visual changes.\n\n";
|
|
9
|
+
export declare const testcafePercyAutomateInstructions = "\nInstall Percy dependencies\n - Install the required dependencies:\n npm install --save-dev @percy/cli @percy/testcafe\n\n---STEP---\nUpdate your test script\n\nInvoke listTestFiles() with the provided directories from user to gather all test files in memory and obtain the generated UUID ---STEP---\nProcess files in STRICT sequential order using tool addPercySnapshotCommands() with below instructions:\n- Start with index 0\n- Then index 1 \n- Then index 2\n- Continue sequentially until the last index\n- DO NOT skip any index numbers\n- DO NOT jump to random indices like 10, 20, 30\n- DO NOT worry about time consuming and any constraints.\n- DO NOT STOP until you add commands in all the files or you reach end of the files.\n\n - Import the Percy library and use the percySnapshot function to take screenshots.\n\nExample:\n```javascript\nimport percySnapshot from '@percy/testcafe';\nfixture('MyFixture')\n .page('https://devexpress.github.io/testcafe/example/');\ntest('Test1', async t => {\n await t.typeText('#developer-name', 'John Doe');\n await percySnapshot(t, 'TestCafe Example');\n});\n```\n\n---STEP---\nRun Percy\n - Use the following command to run your tests with Percy:\n npx percy exec -- testcafe chrome:headless tests\n\n\n---STEP---\nReview the snapshots\n - Go to your Percy project on https://percy.io to review snapshots and approve/reject any visual changes.\n\n";
|
|
10
|
+
export declare const javaPlaywrightJunitInstructions = "\nInstall Percy Automate dependencies\n - Install the latest Percy CLI:\n npm install --save @percy/cli\n - Add the Percy Playwright Java SDK to your pom.xml:\n```xml\n<dependency>\n <groupId>io.percy</groupId>\n <artifactId>percy-playwright-java</artifactId>\n <version>1.0.0</version>\n</dependency>\n```\n\n---STEP---\nUpdate your Automate test script\n - Import the Percy library:\n import io.percy.playwright.Percy;\n - Use the Percy screenshot command to take required screenshots in your Automate session.\n\nExample:\n```java\nPercy percy = new Percy(page);\npercy.screenshot(\"screenshot_1\");\n// With options\npercy.screenshot(\"screenshot_2\", options);\n```\n\n---STEP---\nRun Percy Automate with your tests\n - Use the following command:\n npx percy exec -- <command to run the automate script file>\n\n\n---STEP---\nReview the snapshots\n - Go to your Percy project on https://percy.io to review snapshots and approve/reject any visual changes.\n\n";
|
|
11
|
+
export declare const csharpPlaywrightNunitInstructions = "\nInstall Percy Automate dependencies\n - Install the latest Percy CLI:\n npm install --save @percy/cli\n - Add the Percy Playwright SDK to your .csproj file:\n```xml\n<PackageReference Include=\"PercyIO.Playwright\" Version=\"1.0.0\" />\n```\n\n---STEP---\nUpdate your NUnit Playwright test script\n - Import the Percy library:\n using PercyIO.Playwright;\n - Use the Percy screenshot command to take required screenshots in your Automate session.\n\nExample:\n```csharp\nusing PercyIO.Playwright;\nPercy.Screenshot(page, \"example_screenshot_1\");\n// With options\nPercy.Screenshot(page, \"example_screenshot_2\", options);\n```\n\n---STEP---\nRun Percy Automate with your tests\n - Use the following command:\n npx percy exec -- <command to run the automate script file>\n\n\n---STEP---\nReview the snapshots\n - Go to your Percy project on https://percy.io to review snapshots and approve/reject any visual changes.\n\n";
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { PERCY_SNAPSHOT_INSTRUCTION } from "../common/constants.js";
|
|
2
|
+
export const percyAutomateReviewSnapshotsStep = `
|
|
3
|
+
---STEP---
|
|
4
|
+
Review the snapshots
|
|
5
|
+
- Go to your Percy project on https://percy.io to review snapshots and approve/reject any visual changes.
|
|
6
|
+
`;
|
|
7
|
+
export const pythonPytestSeleniumInstructions = `
|
|
8
|
+
Install Percy Automate dependencies
|
|
9
|
+
- Install Percy CLI:
|
|
10
|
+
npm install --save-dev @percy/cli
|
|
11
|
+
- Install Percy Python SDK for Automate:
|
|
12
|
+
pip install percy-selenium
|
|
13
|
+
|
|
14
|
+
---STEP---
|
|
15
|
+
Update your Pytest test script
|
|
16
|
+
${PERCY_SNAPSHOT_INSTRUCTION}
|
|
17
|
+
- Import the Percy snapshot helper:
|
|
18
|
+
from percy import percy_screenshot
|
|
19
|
+
- In your test, take snapshots at key points:
|
|
20
|
+
percy_screenshot(driver, "Your snapshot name")
|
|
21
|
+
|
|
22
|
+
Example:
|
|
23
|
+
\`\`\`python
|
|
24
|
+
import pytest
|
|
25
|
+
from selenium import webdriver
|
|
26
|
+
from percy import percy_screenshot
|
|
27
|
+
|
|
28
|
+
@pytest.fixture
|
|
29
|
+
def driver():
|
|
30
|
+
driver = webdriver.Chrome()
|
|
31
|
+
yield driver
|
|
32
|
+
driver.quit()
|
|
33
|
+
|
|
34
|
+
def test_homepage(driver):
|
|
35
|
+
driver.get("http://localhost:8000")
|
|
36
|
+
percy_screenshot(driver, "Home page")
|
|
37
|
+
# ... more test steps ...
|
|
38
|
+
percy_screenshot(driver, "After login")
|
|
39
|
+
\`\`\`
|
|
40
|
+
|
|
41
|
+
---STEP---
|
|
42
|
+
Run Percy Automate with your tests
|
|
43
|
+
- Use the following command:
|
|
44
|
+
npx percy exec -- browserstack-sdk pytest
|
|
45
|
+
|
|
46
|
+
${percyAutomateReviewSnapshotsStep}
|
|
47
|
+
`;
|
|
48
|
+
export const pythonPytestPlaywrightInstructions = `
|
|
49
|
+
Install Percy Automate dependencies
|
|
50
|
+
- Install Percy CLI:
|
|
51
|
+
npm install --save @percy/cli
|
|
52
|
+
- Install Percy Playwright SDK for Automate:
|
|
53
|
+
pip install percy-playwright
|
|
54
|
+
|
|
55
|
+
---STEP---
|
|
56
|
+
Update your Playwright test script
|
|
57
|
+
${PERCY_SNAPSHOT_INSTRUCTION}
|
|
58
|
+
- Import the Percy screenshot helper:
|
|
59
|
+
from percy import percy_screenshot
|
|
60
|
+
- In your test, take snapshots at key points:
|
|
61
|
+
percy_screenshot(page, name="Your snapshot name")
|
|
62
|
+
# You can pass \`options\`:
|
|
63
|
+
percy_screenshot(page, name="Your snapshot name", options={ "full_page": True })
|
|
64
|
+
|
|
65
|
+
Example:
|
|
66
|
+
\`\`\`python
|
|
67
|
+
from playwright.sync_api import sync_playwright
|
|
68
|
+
from percy import percy_screenshot
|
|
69
|
+
|
|
70
|
+
def test_visual_regression():
|
|
71
|
+
with sync_playwright() as p:
|
|
72
|
+
browser = p.chromium.launch()
|
|
73
|
+
page = browser.new_page()
|
|
74
|
+
page.goto("http://localhost:8000")
|
|
75
|
+
percy_screenshot(page, name="Home page")
|
|
76
|
+
# ... more test steps ...
|
|
77
|
+
percy_screenshot(page, name="After login", options={ "full_page": True })
|
|
78
|
+
browser.close()
|
|
79
|
+
\`\`\`
|
|
80
|
+
|
|
81
|
+
---STEP---
|
|
82
|
+
Run Percy Automate with your tests
|
|
83
|
+
- Use the following command:
|
|
84
|
+
npx percy exec -- <command to run the automate script file>
|
|
85
|
+
|
|
86
|
+
${percyAutomateReviewSnapshotsStep}
|
|
87
|
+
`;
|
|
88
|
+
export const jsCypressPercyAutomateInstructions = `
|
|
89
|
+
Install Percy Automate dependencies
|
|
90
|
+
- Install Percy CLI:
|
|
91
|
+
npm install --save-dev @percy/cli
|
|
92
|
+
- Install Percy Cypress SDK:
|
|
93
|
+
npm install --save-dev @percy/cypress
|
|
94
|
+
|
|
95
|
+
---STEP---
|
|
96
|
+
Update your Cypress test script
|
|
97
|
+
${PERCY_SNAPSHOT_INSTRUCTION}
|
|
98
|
+
- Import and initialize Percy in your cypress/support/index.js:
|
|
99
|
+
import '@percy/cypress';
|
|
100
|
+
- In your test, take snapshots at key points:
|
|
101
|
+
cy.percySnapshot('Your snapshot name');
|
|
102
|
+
|
|
103
|
+
Example:
|
|
104
|
+
\`\`\`javascript
|
|
105
|
+
describe('Percy Automate Cypress Example', () => {
|
|
106
|
+
it('should take Percy snapshots', () => {
|
|
107
|
+
cy.visit('http://localhost:8000');
|
|
108
|
+
cy.percySnapshot('Home page');
|
|
109
|
+
// ... more test steps ...
|
|
110
|
+
cy.percySnapshot('After login');
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
\`\`\`
|
|
114
|
+
|
|
115
|
+
---STEP---
|
|
116
|
+
Run Percy Automate with your tests
|
|
117
|
+
- Use the following command:
|
|
118
|
+
npx percy exec -- cypress run
|
|
119
|
+
|
|
120
|
+
${percyAutomateReviewSnapshotsStep}
|
|
121
|
+
`;
|
|
122
|
+
export const mochaPercyAutomateInstructions = `
|
|
123
|
+
Install Percy Automate dependencies
|
|
124
|
+
- Install Percy CLI:
|
|
125
|
+
npm install --save @percy/cli
|
|
126
|
+
- Install Percy Selenium SDK:
|
|
127
|
+
npm install @percy/selenium-webdriver@2.0.1
|
|
128
|
+
|
|
129
|
+
---STEP---
|
|
130
|
+
Update your Mocha Automate test script
|
|
131
|
+
- Import the Percy screenshot helper:
|
|
132
|
+
const { percyScreenshot } = require('@percy/selenium-webdriver');
|
|
133
|
+
- Use the Percy screenshot command to take required screenshots in your Automate session:
|
|
134
|
+
await percyScreenshot(driver, 'Screenshot 1');
|
|
135
|
+
options = { percyCSS: 'h1{color:red;}' };
|
|
136
|
+
await percyScreenshot(driver, 'Screenshot 2', options);
|
|
137
|
+
|
|
138
|
+
---STEP---
|
|
139
|
+
Run Percy Automate with your tests
|
|
140
|
+
- Use the following command:
|
|
141
|
+
npx percy exec -- <command to run the automate script file>
|
|
142
|
+
|
|
143
|
+
${percyAutomateReviewSnapshotsStep}
|
|
144
|
+
`;
|
|
145
|
+
// Mocha Percy Playwright Instructions
|
|
146
|
+
export const mochaPercyPlaywrightInstructions = `
|
|
147
|
+
Install Percy Automate dependencies
|
|
148
|
+
- Install the latest Percy CLI:
|
|
149
|
+
npm install --save @percy/cli
|
|
150
|
+
- Install the Percy Playwright SDK:
|
|
151
|
+
npm install @percy/playwright
|
|
152
|
+
|
|
153
|
+
---STEP---
|
|
154
|
+
Update your Mocha Playwright test script
|
|
155
|
+
- Import the Percy screenshot helper:
|
|
156
|
+
const { percyScreenshot } = require("@percy/playwright");
|
|
157
|
+
- Use the Percy screenshot command to take required screenshots in your Automate session.
|
|
158
|
+
|
|
159
|
+
Example:
|
|
160
|
+
\`\`\`javascript
|
|
161
|
+
const { percyScreenshot } = require("@percy/playwright");
|
|
162
|
+
await percyScreenshot(page, "Screenshot 1");
|
|
163
|
+
// With options
|
|
164
|
+
await percyScreenshot(page, "Screenshot 2", { percyCSS: "h1{color:green;}" });
|
|
165
|
+
\`\`\`
|
|
166
|
+
|
|
167
|
+
---STEP---
|
|
168
|
+
Run Percy Automate with your tests
|
|
169
|
+
- Use the following command:
|
|
170
|
+
npx percy exec -- <command to run the automate script file>
|
|
171
|
+
|
|
172
|
+
${percyAutomateReviewSnapshotsStep}
|
|
173
|
+
`;
|
|
174
|
+
export const jestPercyAutomateInstructions = `
|
|
175
|
+
Install or upgrade the BrowserStack SDK:
|
|
176
|
+
- Install the SDK:
|
|
177
|
+
npm i -D browserstack-node-sdk@latest
|
|
178
|
+
- Run the setup:
|
|
179
|
+
npx setup --username "YOUR_USERNAME" --key "YOUR_ACCESS_KEY"
|
|
180
|
+
|
|
181
|
+
---STEP---
|
|
182
|
+
Manually capture screenshots:
|
|
183
|
+
1. Import the BrowserStack Percy SDK in your test script:
|
|
184
|
+
const { percy } = require('browserstack-node-sdk');
|
|
185
|
+
2. Use \`percy.screenshot(driver, name)\` at desired points in your test.
|
|
186
|
+
|
|
187
|
+
Example:
|
|
188
|
+
\`\`\`javascript
|
|
189
|
+
const { percy } = require('browserstack-node-sdk');
|
|
190
|
+
describe("JestJS test", () => {
|
|
191
|
+
let driver;
|
|
192
|
+
const caps = require("../" + conf_file).capabilities;
|
|
193
|
+
|
|
194
|
+
beforeAll(() => {
|
|
195
|
+
driver = new Builder()
|
|
196
|
+
.usingServer("http://example-servername/hub")
|
|
197
|
+
.withCapabilities(caps)
|
|
198
|
+
.build();
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test("my test", async () => {
|
|
202
|
+
// ...
|
|
203
|
+
await percy.screenshot(driver, "My Screenshot");
|
|
204
|
+
// ...
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
\`\`\`
|
|
208
|
+
|
|
209
|
+
---STEP---
|
|
210
|
+
Run your test script:
|
|
211
|
+
- Use the following command:
|
|
212
|
+
npm run [your-test-script-name]-browserstack
|
|
213
|
+
|
|
214
|
+
${percyAutomateReviewSnapshotsStep}
|
|
215
|
+
`;
|
|
216
|
+
export const webdriverioPercyAutomateInstructions = `
|
|
217
|
+
Install or upgrade BrowserStack SDK
|
|
218
|
+
- Install the BrowserStack SDK:
|
|
219
|
+
npm i -D @wdio/browserstack-service
|
|
220
|
+
|
|
221
|
+
---STEP---
|
|
222
|
+
Update your WebdriverIO config file
|
|
223
|
+
1. Set \`percy: true\`
|
|
224
|
+
2. Set a \`projectName\`
|
|
225
|
+
3. Set \`percyCaptureMode: auto\` (or another mode as needed)
|
|
226
|
+
|
|
227
|
+
Example WebdriverIO config:
|
|
228
|
+
\`\`\`js
|
|
229
|
+
exports.config = {
|
|
230
|
+
user: process.env.BROWSERSTACK_USERNAME || 'YOUR_USERNAME',
|
|
231
|
+
key: process.env.BROWSERSTACK_ACCESS_KEY || 'YOUR_ACCESS_KEY',
|
|
232
|
+
hostname: 'hub.browserstack.com',
|
|
233
|
+
services: [
|
|
234
|
+
[
|
|
235
|
+
'browserstack',
|
|
236
|
+
{ browserstackLocal: true, opts: { forcelocal: false }, percy: true, percyCaptureMode: 'auto' }
|
|
237
|
+
],
|
|
238
|
+
],
|
|
239
|
+
// add path to the test file
|
|
240
|
+
}
|
|
241
|
+
\`\`\`
|
|
242
|
+
|
|
243
|
+
---STEP---
|
|
244
|
+
(Optional) Manually capture screenshots
|
|
245
|
+
1. Import the BrowserStack Percy SDK in your test script:
|
|
246
|
+
const { percy } = require('browserstack-node-sdk');
|
|
247
|
+
2. Add the \`await percy.screenshot(driver, name)\` method at required points in your test script.
|
|
248
|
+
|
|
249
|
+
Example:
|
|
250
|
+
\`\`\`javascript
|
|
251
|
+
const { percy } = require('browserstack-node-sdk');
|
|
252
|
+
2. Add the \`await percy.screenshot(driver, name)\` method at required points in your test script.
|
|
253
|
+
|
|
254
|
+
Example:
|
|
255
|
+
\`\`\`javascript
|
|
256
|
+
const { percy } = require('browserstack-node-sdk');
|
|
257
|
+
describe("WebdriverIO Test", () => {
|
|
258
|
+
it("my test", async () => {
|
|
259
|
+
// ....
|
|
260
|
+
await percy.screenshot(driver, "My Screenshot")
|
|
261
|
+
// ....
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
\`\`\`
|
|
265
|
+
|
|
266
|
+
---STEP---
|
|
267
|
+
Run your test script
|
|
268
|
+
- Use the commands defined in your package.json file to run the tests on BrowserStack.
|
|
269
|
+
|
|
270
|
+
${percyAutomateReviewSnapshotsStep}
|
|
271
|
+
`;
|
|
272
|
+
export const testcafePercyAutomateInstructions = `
|
|
273
|
+
Install Percy dependencies
|
|
274
|
+
- Install the required dependencies:
|
|
275
|
+
npm install --save-dev @percy/cli @percy/testcafe
|
|
276
|
+
|
|
277
|
+
---STEP---
|
|
278
|
+
Update your test script
|
|
279
|
+
${PERCY_SNAPSHOT_INSTRUCTION}
|
|
280
|
+
- Import the Percy library and use the percySnapshot function to take screenshots.
|
|
281
|
+
|
|
282
|
+
Example:
|
|
283
|
+
\`\`\`javascript
|
|
284
|
+
import percySnapshot from '@percy/testcafe';
|
|
285
|
+
fixture('MyFixture')
|
|
286
|
+
.page('https://devexpress.github.io/testcafe/example/');
|
|
287
|
+
test('Test1', async t => {
|
|
288
|
+
await t.typeText('#developer-name', 'John Doe');
|
|
289
|
+
await percySnapshot(t, 'TestCafe Example');
|
|
290
|
+
});
|
|
291
|
+
\`\`\`
|
|
292
|
+
|
|
293
|
+
---STEP---
|
|
294
|
+
Run Percy
|
|
295
|
+
- Use the following command to run your tests with Percy:
|
|
296
|
+
npx percy exec -- testcafe chrome:headless tests
|
|
297
|
+
|
|
298
|
+
${percyAutomateReviewSnapshotsStep}
|
|
299
|
+
`;
|
|
300
|
+
// Java Playwright Percy Automate Instructions
|
|
301
|
+
export const javaPlaywrightJunitInstructions = `
|
|
302
|
+
Install Percy Automate dependencies
|
|
303
|
+
- Install the latest Percy CLI:
|
|
304
|
+
npm install --save @percy/cli
|
|
305
|
+
- Add the Percy Playwright Java SDK to your pom.xml:
|
|
306
|
+
\`\`\`xml
|
|
307
|
+
<dependency>
|
|
308
|
+
<groupId>io.percy</groupId>
|
|
309
|
+
<artifactId>percy-playwright-java</artifactId>
|
|
310
|
+
<version>1.0.0</version>
|
|
311
|
+
</dependency>
|
|
312
|
+
\`\`\`
|
|
313
|
+
|
|
314
|
+
---STEP---
|
|
315
|
+
Update your Automate test script
|
|
316
|
+
- Import the Percy library:
|
|
317
|
+
import io.percy.playwright.Percy;
|
|
318
|
+
- Use the Percy screenshot command to take required screenshots in your Automate session.
|
|
319
|
+
|
|
320
|
+
Example:
|
|
321
|
+
\`\`\`java
|
|
322
|
+
Percy percy = new Percy(page);
|
|
323
|
+
percy.screenshot("screenshot_1");
|
|
324
|
+
// With options
|
|
325
|
+
percy.screenshot("screenshot_2", options);
|
|
326
|
+
\`\`\`
|
|
327
|
+
|
|
328
|
+
---STEP---
|
|
329
|
+
Run Percy Automate with your tests
|
|
330
|
+
- Use the following command:
|
|
331
|
+
npx percy exec -- <command to run the automate script file>
|
|
332
|
+
|
|
333
|
+
${percyAutomateReviewSnapshotsStep}
|
|
334
|
+
`;
|
|
335
|
+
// C# Playwright NUnit Percy Automate Instructions
|
|
336
|
+
export const csharpPlaywrightNunitInstructions = `
|
|
337
|
+
Install Percy Automate dependencies
|
|
338
|
+
- Install the latest Percy CLI:
|
|
339
|
+
npm install --save @percy/cli
|
|
340
|
+
- Add the Percy Playwright SDK to your .csproj file:
|
|
341
|
+
\`\`\`xml
|
|
342
|
+
<PackageReference Include="PercyIO.Playwright" Version="1.0.0" />
|
|
343
|
+
\`\`\`
|
|
344
|
+
|
|
345
|
+
---STEP---
|
|
346
|
+
Update your NUnit Playwright test script
|
|
347
|
+
- Import the Percy library:
|
|
348
|
+
using PercyIO.Playwright;
|
|
349
|
+
- Use the Percy screenshot command to take required screenshots in your Automate session.
|
|
350
|
+
|
|
351
|
+
Example:
|
|
352
|
+
\`\`\`csharp
|
|
353
|
+
using PercyIO.Playwright;
|
|
354
|
+
Percy.Screenshot(page, "example_screenshot_1");
|
|
355
|
+
// With options
|
|
356
|
+
Percy.Screenshot(page, "example_screenshot_2", options);
|
|
357
|
+
\`\`\`
|
|
358
|
+
|
|
359
|
+
---STEP---
|
|
360
|
+
Run Percy Automate with your tests
|
|
361
|
+
- Use the following command:
|
|
362
|
+
npx percy exec -- <command to run the automate script file>
|
|
363
|
+
|
|
364
|
+
${percyAutomateReviewSnapshotsStep}
|
|
365
|
+
`;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ConfigMapping } from "./types.js";
|
|
2
|
+
export declare const SUPPORTED_CONFIGURATIONS: ConfigMapping;
|
|
3
|
+
/**
|
|
4
|
+
* Utility function to check if a given language, driver, and testing framework
|
|
5
|
+
* are supported by Percy Automate.
|
|
6
|
+
* This now expects the structure: language -> driver -> framework
|
|
7
|
+
*/
|
|
8
|
+
export declare function isPercyAutomateFrameworkSupported(language: string, driver: string, framework: string): boolean;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as instructions from "./constants.js";
|
|
2
|
+
export const SUPPORTED_CONFIGURATIONS = {
|
|
3
|
+
python: {
|
|
4
|
+
selenium: {
|
|
5
|
+
pytest: {
|
|
6
|
+
instructions: instructions.pythonPytestSeleniumInstructions,
|
|
7
|
+
},
|
|
8
|
+
},
|
|
9
|
+
playwright: {
|
|
10
|
+
pytest: {
|
|
11
|
+
instructions: instructions.pythonPytestPlaywrightInstructions,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
java: {
|
|
16
|
+
playwright: {
|
|
17
|
+
junit: { instructions: instructions.javaPlaywrightJunitInstructions },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
nodejs: {
|
|
21
|
+
selenium: {
|
|
22
|
+
mocha: { instructions: instructions.mochaPercyAutomateInstructions },
|
|
23
|
+
jest: { instructions: instructions.jestPercyAutomateInstructions },
|
|
24
|
+
webdriverio: {
|
|
25
|
+
instructions: instructions.webdriverioPercyAutomateInstructions,
|
|
26
|
+
},
|
|
27
|
+
testcafe: {
|
|
28
|
+
instructions: instructions.testcafePercyAutomateInstructions,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
playwright: {
|
|
32
|
+
mocha: { instructions: instructions.mochaPercyPlaywrightInstructions },
|
|
33
|
+
jest: { instructions: instructions.jestPercyAutomateInstructions },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Utility function to check if a given language, driver, and testing framework
|
|
39
|
+
* are supported by Percy Automate.
|
|
40
|
+
* This now expects the structure: language -> driver -> framework
|
|
41
|
+
*/
|
|
42
|
+
export function isPercyAutomateFrameworkSupported(language, driver, framework) {
|
|
43
|
+
const languageConfig = SUPPORTED_CONFIGURATIONS[language];
|
|
44
|
+
if (!languageConfig)
|
|
45
|
+
return false;
|
|
46
|
+
const driverConfig = languageConfig[driver];
|
|
47
|
+
if (!driverConfig)
|
|
48
|
+
return false;
|
|
49
|
+
return !!driverConfig[framework];
|
|
50
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SUPPORTED_CONFIGURATIONS } from "./frameworks.js";
|
|
2
|
+
export function runPercyAutomateOnly(input, percyToken) {
|
|
3
|
+
const steps = [];
|
|
4
|
+
// Assume configuration is supported due to guardrails at orchestration layer
|
|
5
|
+
const languageConfig = SUPPORTED_CONFIGURATIONS[input.detectedLanguage];
|
|
6
|
+
const driverConfig = languageConfig[input.detectedBrowserAutomationFramework];
|
|
7
|
+
const testingFrameworkConfig = driverConfig
|
|
8
|
+
? driverConfig[input.detectedTestingFramework]
|
|
9
|
+
: undefined;
|
|
10
|
+
// Generate instructions for the supported configuration with project name
|
|
11
|
+
const instructions = testingFrameworkConfig
|
|
12
|
+
? testingFrameworkConfig.instructions
|
|
13
|
+
: "";
|
|
14
|
+
// Prepend a step to set the Percy token in the environment
|
|
15
|
+
steps.push({
|
|
16
|
+
type: "instruction",
|
|
17
|
+
title: "Set Percy Token in Environment",
|
|
18
|
+
content: `---STEP---Set the environment variable generated for your project before running your tests:\n\nexport PERCY_TOKEN="${percyToken}"\n\n(For Windows, use 'setx PERCY_TOKEN "${percyToken}"' or 'set PERCY_TOKEN=${percyToken}' as appropriate.)---STEP---`,
|
|
19
|
+
});
|
|
20
|
+
steps.push({
|
|
21
|
+
type: "instruction",
|
|
22
|
+
title: `Percy Automate Setup for ${input.detectedLanguage} with ${input.detectedTestingFramework}`,
|
|
23
|
+
content: instructions,
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
steps,
|
|
27
|
+
requiresPercy: true,
|
|
28
|
+
missingDependencies: [],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { runPercyAutomateOnly } from "./handler.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type for Percy Automate configuration mapping.
|
|
3
|
+
* Structure: language -> driver -> testingFramework -> { instructions: string }
|
|
4
|
+
*/
|
|
5
|
+
export type ConfigMapping = {
|
|
6
|
+
[language: string]: {
|
|
7
|
+
[driver: string]: {
|
|
8
|
+
[framework: string]: {
|
|
9
|
+
instructions: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|