@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
|
@@ -1,365 +0,0 @@
|
|
|
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
|
-
`;
|
|
@@ -1,8 +0,0 @@
|
|
|
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;
|
|
@@ -1,50 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { runPercyAutomateOnly } from "./handler.js";
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const javaSeleniumInstructions = "\nImport the BrowserStack Percy SDK in your test script:\nAdd the Percy import to your test file.\n\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\nAdd screenshot capture method at required points:\nUse the `PercySDK.screenshot(driver, name)` method at points in your test script where you want to capture screenshots.\n\nHere's an example:\n\n```java\n// ...imports\nimport com.browserstack.PercySDK;\n\npublic class YourTestClass extends YourBaseTest {\n @Test\n public void test() throws Exception {\n // your test logic\n // ...\n \n // Capture a Percy screenshot\n PercySDK.screenshot(driver, \"My Screenshot Name\");\n \n // ...\n // more test logic\n }\n}\n```\n";
|
|
2
|
-
export declare const nodejsSeleniumInstructions = "\nImport the BrowserStack Percy SDK in your test script:\nAdd the Percy import to your test file.\n\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\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.screenshot(driver, \"My Snapshot\")\n // ....\n });\n})\n```\n";
|
|
3
|
-
export declare const webdriverioPercyInstructions = "\nEnable Percy in `wdio.conf.js`:\nIn your WebdriverIO configuration file, modify the 'browserstack' service options to enable Percy.\n\n- Set `percy: true`.\n- Set a `projectName`. This is required and will be used for both your Automate and Percy projects.\n- Set `percyCaptureMode`. The default `manual` as we are adding screenshot commands manually.\n\nHere's how to modify the service configuration:\n```javascript\n// in wdio.conf.js\n\nexports.config = {\n // ... other configs\n services: [\n [\n 'browserstack',\n { \n // ... other service options\n percy: true,\n percyCaptureMode: 'manual' // or 'auto', etc.\n },\n ],\n ],\n\n commonCapabilities: {\n 'bstack:options': {\n projectName: \"My Percy Project\", // This is required for Percy\n // ... other common capabilities\n }\n },\n // ... rest of your config\n};\n```\n\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\n---STEP---\n\nManually Capturing Screenshots (Optional):\nIf you set `percyCaptureMode: 'manual'` or want to take extra screenshots in `auto` mode, you need to add screenshot commands to your tests.\n\nFirst, install `browserstack-node-sdk`:\n```bash\nnpm install browserstack-node-sdk\n```\n\nThen, in your test script, import `percy` and use it to take a snapshot:\n```javascript\n// your_test_file.js\nconst { percy } = require('browserstack-node-sdk');\n\ndescribe(\"My WebdriverIO Test\", () => {\n it(\"should take a percy snapshot\", async () => {\n // ... your test logic (e.g., browser.url('https://example.com'))\n \n // Capture a Percy screenshot\n await percy.screenshot(driver, \"My Snapshot Name\");\n \n // ... more test logic\n });\n});\n```\n";
|
|
4
|
-
export declare const csharpSeleniumInstructions = "\nImport the BrowserStack Percy SDK in your test script:\nAdd the Percy import to your test file.\n\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\nAdd screenshot capture method at required points:\nUse the `PercySDK.Screenshot(driver, name)` method at points in your test script where you want to capture screenshots.\n\nHere's an example:\n\n```csharp\nusing BrowserStackSDK.Percy;\nnamespace Tests;\n\npublic class MyTest\n{\n [Test]\n public void SampleTest()\n {\n // your test logic\n // ...\n \n // Capture a Percy screenshot\n PercySDK.Screenshot(driver, \"Screenshot name\");\n \n // ...\n // more test logic\n }\n}\n```\n";
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as constants from "./constants.js";
|
|
2
|
-
export const PERCY_INSTRUCTIONS = {
|
|
3
|
-
java: {
|
|
4
|
-
selenium: {
|
|
5
|
-
testng: { instructions: constants.javaSeleniumInstructions },
|
|
6
|
-
cucumber: { instructions: constants.javaSeleniumInstructions },
|
|
7
|
-
junit4: { instructions: constants.javaSeleniumInstructions },
|
|
8
|
-
junit5: { instructions: constants.javaSeleniumInstructions },
|
|
9
|
-
selenide: { instructions: constants.javaSeleniumInstructions },
|
|
10
|
-
jbehave: { instructions: constants.javaSeleniumInstructions },
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
csharp: {
|
|
14
|
-
selenium: {
|
|
15
|
-
nunit: { instructions: constants.csharpSeleniumInstructions },
|
|
16
|
-
xunit: { instructions: constants.csharpSeleniumInstructions },
|
|
17
|
-
specflow: { instructions: constants.csharpSeleniumInstructions },
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
nodejs: {
|
|
21
|
-
selenium: {
|
|
22
|
-
mocha: { instructions: constants.nodejsSeleniumInstructions },
|
|
23
|
-
jest: { instructions: constants.nodejsSeleniumInstructions },
|
|
24
|
-
webdriverio: { instructions: constants.webdriverioPercyInstructions },
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { RunTestsInstructionResult } from "../common/types.js";
|
|
2
|
-
import { RunTestsOnBrowserStackInput } from "../common/schema.js";
|
|
3
|
-
import { BrowserStackConfig } from "../../../lib/types.js";
|
|
4
|
-
export declare function runPercyWithBrowserstackSDK(input: RunTestsOnBrowserStackInput, config: BrowserStackConfig): RunTestsInstructionResult;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { getBrowserStackAuth } from "../../../lib/get-auth.js";
|
|
2
|
-
import { getSDKPrefixCommand } from "../bstack/commands.js";
|
|
3
|
-
import { generateBrowserStackYMLInstructions } from "../bstack/configUtils.js";
|
|
4
|
-
import { getInstructionsForProjectConfiguration } from "../common/instructionUtils.js";
|
|
5
|
-
import { formatPercyInstructions, getPercyInstructions, } from "./instructions.js";
|
|
6
|
-
export function runPercyWithBrowserstackSDK(input, config) {
|
|
7
|
-
const steps = [];
|
|
8
|
-
const authString = getBrowserStackAuth(config);
|
|
9
|
-
const [username, accessKey] = authString.split(":");
|
|
10
|
-
// Check if Percy is supported for this configuration
|
|
11
|
-
const percyResult = getPercyInstructions(input.detectedLanguage, input.detectedBrowserAutomationFramework, input.detectedTestingFramework);
|
|
12
|
-
if (!percyResult) {
|
|
13
|
-
// Percy not supported for this configuration
|
|
14
|
-
return {
|
|
15
|
-
steps: [
|
|
16
|
-
{
|
|
17
|
-
type: "error",
|
|
18
|
-
title: "Percy Not Supported",
|
|
19
|
-
content: `Percy is not supported for this ${input.detectedBrowserAutomationFramework} framework configuration. Please use BrowserStack SDK only mode or try a different framework combination.`,
|
|
20
|
-
isError: true,
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
requiresPercy: true,
|
|
24
|
-
shouldSkipFormatting: true,
|
|
25
|
-
missingDependencies: [],
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
// Handle frameworks with unique setup instructions that don't use browserstack.yml
|
|
29
|
-
if (input.detectedBrowserAutomationFramework === "cypress" ||
|
|
30
|
-
input.detectedTestingFramework === "webdriverio") {
|
|
31
|
-
const frameworkInstructions = getInstructionsForProjectConfiguration(input.detectedBrowserAutomationFramework, input.detectedTestingFramework, input.detectedLanguage, username, accessKey);
|
|
32
|
-
if (frameworkInstructions && frameworkInstructions.setup) {
|
|
33
|
-
steps.push({
|
|
34
|
-
type: "instruction",
|
|
35
|
-
title: "Framework-Specific Setup",
|
|
36
|
-
content: frameworkInstructions.setup,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
steps.push({
|
|
40
|
-
type: "instruction",
|
|
41
|
-
title: "Percy Setup (BrowserStack SDK + Percy)",
|
|
42
|
-
content: formatPercyInstructions(percyResult),
|
|
43
|
-
});
|
|
44
|
-
if (frameworkInstructions && frameworkInstructions.run) {
|
|
45
|
-
steps.push({
|
|
46
|
-
type: "instruction",
|
|
47
|
-
title: "Run the tests",
|
|
48
|
-
content: frameworkInstructions.run,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
steps,
|
|
53
|
-
requiresPercy: true,
|
|
54
|
-
missingDependencies: [],
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
// Default flow using browserstack.yml with Percy
|
|
58
|
-
const sdkSetupCommand = getSDKPrefixCommand(input.detectedLanguage, input.detectedTestingFramework, username, accessKey);
|
|
59
|
-
if (sdkSetupCommand) {
|
|
60
|
-
steps.push({
|
|
61
|
-
type: "instruction",
|
|
62
|
-
title: "Install BrowserStack SDK",
|
|
63
|
-
content: sdkSetupCommand,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
const ymlInstructions = generateBrowserStackYMLInstructions(input.desiredPlatforms, true, input.projectName);
|
|
67
|
-
if (ymlInstructions) {
|
|
68
|
-
steps.push({
|
|
69
|
-
type: "instruction",
|
|
70
|
-
title: "Configure browserstack.yml",
|
|
71
|
-
content: ymlInstructions,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
const frameworkInstructions = getInstructionsForProjectConfiguration(input.detectedBrowserAutomationFramework, input.detectedTestingFramework, input.detectedLanguage, username, accessKey);
|
|
75
|
-
if (frameworkInstructions && frameworkInstructions.setup) {
|
|
76
|
-
steps.push({
|
|
77
|
-
type: "instruction",
|
|
78
|
-
title: "Framework-Specific Setup",
|
|
79
|
-
content: frameworkInstructions.setup,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
steps.push({
|
|
83
|
-
type: "instruction",
|
|
84
|
-
title: "Percy Setup (BrowserStack SDK + Percy)",
|
|
85
|
-
content: formatPercyInstructions(percyResult),
|
|
86
|
-
});
|
|
87
|
-
if (frameworkInstructions && frameworkInstructions.run) {
|
|
88
|
-
steps.push({
|
|
89
|
-
type: "instruction",
|
|
90
|
-
title: "Run the tests",
|
|
91
|
-
content: frameworkInstructions.run,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
steps,
|
|
96
|
-
requiresPercy: true,
|
|
97
|
-
missingDependencies: [],
|
|
98
|
-
};
|
|
99
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { SDKSupportedBrowserAutomationFramework, SDKSupportedLanguage, SDKSupportedTestingFramework } from "../common/types.js";
|
|
2
|
-
export declare function getPercyInstructions(language: SDKSupportedLanguage, automationFramework: SDKSupportedBrowserAutomationFramework, testingFramework: SDKSupportedTestingFramework): {
|
|
3
|
-
instructions: string;
|
|
4
|
-
} | null;
|
|
5
|
-
export declare function formatPercyInstructions(instructions: {
|
|
6
|
-
instructions: string;
|
|
7
|
-
}): string;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type for Percy + BrowserStack SDK configuration mapping.
|
|
3
|
-
* Structure: language -> automationFramework -> testingFramework -> { instructions: (bsdkToken: string) => string }
|
|
4
|
-
*/
|
|
5
|
-
export type ConfigMapping = {
|
|
6
|
-
[language: string]: {
|
|
7
|
-
[automationFramework: string]: {
|
|
8
|
-
[testingFramework: string]: {
|
|
9
|
-
instructions: string;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
};
|