@browserstack/mcp-server 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +88 -2
  2. package/dist/lib/device-cache.js +20 -17
  3. package/dist/lib/inmemory-store.d.ts +1 -0
  4. package/dist/lib/inmemory-store.js +1 -0
  5. package/dist/lib/utils.d.ts +5 -0
  6. package/dist/lib/utils.js +27 -0
  7. package/dist/server-factory.js +6 -0
  8. package/dist/tools/add-percy-snapshots.d.ts +5 -0
  9. package/dist/tools/add-percy-snapshots.js +17 -0
  10. package/dist/tools/appautomate-utils/appium-sdk/config-generator.d.ts +1 -0
  11. package/dist/tools/appautomate-utils/appium-sdk/config-generator.js +50 -0
  12. package/dist/tools/appautomate-utils/appium-sdk/constants.d.ts +23 -0
  13. package/dist/tools/appautomate-utils/appium-sdk/constants.js +43 -0
  14. package/dist/tools/appautomate-utils/appium-sdk/formatter.d.ts +8 -0
  15. package/dist/tools/appautomate-utils/appium-sdk/formatter.js +59 -0
  16. package/dist/tools/appautomate-utils/appium-sdk/handler.d.ts +3 -0
  17. package/dist/tools/appautomate-utils/appium-sdk/handler.js +52 -0
  18. package/dist/tools/appautomate-utils/appium-sdk/index.d.ts +7 -0
  19. package/dist/tools/appautomate-utils/appium-sdk/index.js +8 -0
  20. package/dist/tools/appautomate-utils/appium-sdk/instructions.d.ts +3 -0
  21. package/dist/tools/appautomate-utils/appium-sdk/instructions.js +47 -0
  22. package/dist/tools/appautomate-utils/appium-sdk/languages/csharp.d.ts +2 -0
  23. package/dist/tools/appautomate-utils/appium-sdk/languages/csharp.js +78 -0
  24. package/dist/tools/appautomate-utils/appium-sdk/languages/java.d.ts +8 -0
  25. package/dist/tools/appautomate-utils/appium-sdk/languages/java.js +87 -0
  26. package/dist/tools/appautomate-utils/appium-sdk/languages/nodejs.d.ts +3 -0
  27. package/dist/tools/appautomate-utils/appium-sdk/languages/nodejs.js +194 -0
  28. package/dist/tools/appautomate-utils/appium-sdk/languages/python.d.ts +3 -0
  29. package/dist/tools/appautomate-utils/appium-sdk/languages/python.js +76 -0
  30. package/dist/tools/appautomate-utils/appium-sdk/languages/ruby.d.ts +2 -0
  31. package/dist/tools/appautomate-utils/appium-sdk/languages/ruby.js +85 -0
  32. package/dist/tools/appautomate-utils/appium-sdk/types.d.ts +57 -0
  33. package/dist/tools/appautomate-utils/appium-sdk/types.js +54 -0
  34. package/dist/tools/appautomate-utils/appium-sdk/utils.d.ts +17 -0
  35. package/dist/tools/appautomate-utils/appium-sdk/utils.js +64 -0
  36. package/dist/tools/appautomate-utils/{appautomate.d.ts → native-execution/appautomate.d.ts} +1 -1
  37. package/dist/tools/appautomate-utils/{appautomate.js → native-execution/appautomate.js} +2 -2
  38. package/dist/tools/appautomate-utils/native-execution/constants.d.ts +10 -0
  39. package/dist/tools/appautomate-utils/native-execution/constants.js +36 -0
  40. package/dist/tools/appautomate-utils/native-execution/types.d.ts +19 -0
  41. package/dist/tools/appautomate-utils/{types.js → native-execution/types.js} +5 -1
  42. package/dist/tools/appautomate.js +25 -40
  43. package/dist/tools/bstack-sdk.d.ts +2 -15
  44. package/dist/tools/bstack-sdk.js +10 -119
  45. package/dist/tools/build-insights.d.ts +7 -0
  46. package/dist/tools/build-insights.js +67 -0
  47. package/dist/tools/list-test-files.d.ts +2 -0
  48. package/dist/tools/list-test-files.js +36 -0
  49. package/dist/tools/percy-sdk.d.ts +4 -0
  50. package/dist/tools/percy-sdk.js +71 -0
  51. package/dist/tools/percy-snapshot-utils/constants.d.ts +16 -0
  52. package/dist/tools/percy-snapshot-utils/constants.js +500 -0
  53. package/dist/tools/percy-snapshot-utils/detect-test-files.d.ts +10 -0
  54. package/dist/tools/percy-snapshot-utils/detect-test-files.js +175 -0
  55. package/dist/tools/percy-snapshot-utils/types.d.ts +15 -0
  56. package/dist/tools/percy-snapshot-utils/utils.d.ts +4 -0
  57. package/dist/tools/percy-snapshot-utils/utils.js +30 -0
  58. package/dist/tools/rca-agent-utils/constants.d.ts +13 -0
  59. package/dist/tools/rca-agent-utils/constants.js +24 -0
  60. package/dist/tools/rca-agent-utils/format-rca.d.ts +1 -0
  61. package/dist/tools/rca-agent-utils/format-rca.js +37 -0
  62. package/dist/tools/rca-agent-utils/get-build-id.d.ts +1 -0
  63. package/dist/tools/rca-agent-utils/get-build-id.js +18 -0
  64. package/dist/tools/rca-agent-utils/get-failed-test-id.d.ts +2 -0
  65. package/dist/tools/rca-agent-utils/get-failed-test-id.js +69 -0
  66. package/dist/tools/rca-agent-utils/rca-data.d.ts +9 -0
  67. package/dist/tools/rca-agent-utils/rca-data.js +196 -0
  68. package/dist/tools/rca-agent-utils/types.d.ts +48 -0
  69. package/dist/tools/rca-agent-utils/types.js +20 -0
  70. package/dist/tools/rca-agent.d.ts +14 -0
  71. package/dist/tools/rca-agent.js +119 -0
  72. package/dist/tools/review-agent-utils/build-counts.d.ts +7 -0
  73. package/dist/tools/review-agent-utils/build-counts.js +44 -0
  74. package/dist/tools/review-agent-utils/percy-approve-reject.d.ts +6 -0
  75. package/dist/tools/review-agent-utils/percy-approve-reject.js +39 -0
  76. package/dist/tools/review-agent-utils/percy-diffs.d.ts +9 -0
  77. package/dist/tools/review-agent-utils/percy-diffs.js +35 -0
  78. package/dist/tools/review-agent-utils/percy-snapshots.d.ts +11 -0
  79. package/dist/tools/review-agent-utils/percy-snapshots.js +58 -0
  80. package/dist/tools/review-agent.d.ts +5 -0
  81. package/dist/tools/review-agent.js +56 -0
  82. package/dist/tools/run-percy-scan.d.ts +8 -0
  83. package/dist/tools/run-percy-scan.js +37 -0
  84. package/dist/tools/sdk-utils/{commands.d.ts → bstack/commands.d.ts} +1 -1
  85. package/dist/tools/sdk-utils/bstack/commands.js +88 -0
  86. package/dist/tools/sdk-utils/bstack/configUtils.d.ts +4 -0
  87. package/dist/tools/sdk-utils/bstack/configUtils.js +66 -0
  88. package/dist/tools/sdk-utils/bstack/constants.d.ts +58 -0
  89. package/dist/tools/sdk-utils/{constants.js → bstack/constants.js} +117 -78
  90. package/dist/tools/sdk-utils/{constants.d.ts → bstack/frameworks.d.ts} +1 -1
  91. package/dist/tools/sdk-utils/bstack/frameworks.js +57 -0
  92. package/dist/tools/sdk-utils/bstack/index.d.ts +4 -0
  93. package/dist/tools/sdk-utils/bstack/index.js +5 -0
  94. package/dist/tools/sdk-utils/bstack/sdkHandler.d.ts +4 -0
  95. package/dist/tools/sdk-utils/bstack/sdkHandler.js +74 -0
  96. package/dist/tools/sdk-utils/common/constants.d.ts +10 -0
  97. package/dist/tools/sdk-utils/common/constants.js +86 -0
  98. package/dist/tools/sdk-utils/common/formatUtils.d.ts +5 -0
  99. package/dist/tools/sdk-utils/common/formatUtils.js +27 -0
  100. package/dist/tools/sdk-utils/common/index.d.ts +3 -0
  101. package/dist/tools/sdk-utils/common/index.js +4 -0
  102. package/dist/tools/sdk-utils/common/instructionUtils.d.ts +8 -0
  103. package/dist/tools/sdk-utils/common/instructionUtils.js +20 -0
  104. package/dist/tools/sdk-utils/common/schema.d.ts +73 -0
  105. package/dist/tools/sdk-utils/common/schema.js +51 -0
  106. package/dist/tools/sdk-utils/common/types.d.ts +66 -0
  107. package/dist/tools/sdk-utils/{types.js → common/types.js} +15 -2
  108. package/dist/tools/sdk-utils/common/utils.d.ts +25 -0
  109. package/dist/tools/sdk-utils/common/utils.js +90 -0
  110. package/dist/tools/sdk-utils/handler.d.ts +4 -0
  111. package/dist/tools/sdk-utils/handler.js +119 -0
  112. package/dist/tools/sdk-utils/percy-automate/constants.d.ts +11 -0
  113. package/dist/tools/sdk-utils/percy-automate/constants.js +338 -0
  114. package/dist/tools/sdk-utils/percy-automate/frameworks.d.ts +8 -0
  115. package/dist/tools/sdk-utils/percy-automate/frameworks.js +50 -0
  116. package/dist/tools/sdk-utils/percy-automate/handler.d.ts +3 -0
  117. package/dist/tools/sdk-utils/percy-automate/handler.js +30 -0
  118. package/dist/tools/sdk-utils/percy-automate/index.d.ts +1 -0
  119. package/dist/tools/sdk-utils/percy-automate/index.js +2 -0
  120. package/dist/tools/sdk-utils/percy-automate/types.d.ts +13 -0
  121. package/dist/tools/sdk-utils/percy-automate/types.js +1 -0
  122. package/dist/tools/sdk-utils/percy-bstack/constants.d.ts +4 -0
  123. package/dist/tools/sdk-utils/{percy → percy-bstack}/constants.js +13 -39
  124. package/dist/tools/sdk-utils/percy-bstack/frameworks.d.ts +2 -0
  125. package/dist/tools/sdk-utils/percy-bstack/frameworks.js +27 -0
  126. package/dist/tools/sdk-utils/percy-bstack/handler.d.ts +4 -0
  127. package/dist/tools/sdk-utils/percy-bstack/handler.js +99 -0
  128. package/dist/tools/sdk-utils/percy-bstack/index.d.ts +4 -0
  129. package/dist/tools/sdk-utils/percy-bstack/index.js +4 -0
  130. package/dist/tools/sdk-utils/percy-bstack/instructions.d.ts +7 -0
  131. package/dist/tools/sdk-utils/{percy → percy-bstack}/instructions.js +5 -9
  132. package/dist/tools/sdk-utils/percy-bstack/types.d.ts +13 -0
  133. package/dist/tools/sdk-utils/percy-bstack/types.js +5 -0
  134. package/dist/tools/sdk-utils/percy-web/constants.d.ts +41 -0
  135. package/dist/tools/sdk-utils/percy-web/constants.js +883 -0
  136. package/dist/tools/sdk-utils/percy-web/fetchPercyToken.d.ts +4 -0
  137. package/dist/tools/sdk-utils/percy-web/fetchPercyToken.js +32 -0
  138. package/dist/tools/sdk-utils/percy-web/frameworks.d.ts +7 -0
  139. package/dist/tools/sdk-utils/percy-web/frameworks.js +103 -0
  140. package/dist/tools/sdk-utils/percy-web/handler.d.ts +4 -0
  141. package/dist/tools/sdk-utils/percy-web/handler.js +27 -0
  142. package/dist/tools/sdk-utils/percy-web/index.d.ts +4 -0
  143. package/dist/tools/sdk-utils/percy-web/index.js +4 -0
  144. package/dist/tools/sdk-utils/percy-web/types.d.ts +12 -0
  145. package/dist/tools/sdk-utils/percy-web/types.js +1 -0
  146. package/dist/tools/testmanagement-utils/create-testrun.d.ts +4 -4
  147. package/dist/tools/testmanagement-utils/update-testrun.d.ts +4 -4
  148. package/package.json +2 -1
  149. package/dist/tools/appautomate-utils/types.d.ts +0 -5
  150. package/dist/tools/sdk-utils/commands.js +0 -65
  151. package/dist/tools/sdk-utils/instructions.d.ts +0 -6
  152. package/dist/tools/sdk-utils/instructions.js +0 -99
  153. package/dist/tools/sdk-utils/percy/constants.d.ts +0 -3
  154. package/dist/tools/sdk-utils/percy/instructions.d.ts +0 -10
  155. package/dist/tools/sdk-utils/percy/types.d.ts +0 -5
  156. package/dist/tools/sdk-utils/types.d.ts +0 -40
  157. /package/dist/tools/{sdk-utils/percy → percy-snapshot-utils}/types.js +0 -0
@@ -0,0 +1,883 @@
1
+ import { PERCY_SNAPSHOT_INSTRUCTION } from "../common/constants.js";
2
+ export const percyReviewSnapshotsStep = `
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 pythonInstructionsSnapshot = `
8
+ Example:
9
+ \`\`\`python
10
+ - Import the Percy snapshot helper:
11
+ from selenium import webdriver
12
+ from percy import percy_snapshot
13
+
14
+ driver = webdriver.Chrome()
15
+ driver.get('http://localhost:8000')
16
+ percy_snapshot(driver, 'Home page')
17
+ # ... more test steps ...
18
+ percy_snapshot(driver, 'After login')
19
+ \`\`\`
20
+ `;
21
+ export const nodejsInstructionsSnapshot = `
22
+ - Import the Percy snapshot helper:
23
+ const { percySnapshot } = require('@percy/selenium-js');
24
+ - In your test, take snapshots like this:
25
+ await percySnapshot(driver, "Your snapshot name");
26
+
27
+ Example:
28
+ \`\`\`javascript
29
+ const { Builder } = require('selenium-webdriver');
30
+ const percySnapshot = require('@percy/selenium-webdriver');
31
+
32
+ const driver = await new Builder().forBrowser('chrome').build();
33
+ await driver.get('http://localhost:8000');
34
+ await percySnapshot(driver, 'Home page');
35
+ \`\`\`
36
+ `;
37
+ export const javaInstructionsSnapshot = `
38
+ - Import the Percy snapshot helper:
39
+ import io.percy.selenium.Percy;
40
+ - In your test, take snapshots like this:
41
+ Percy percy = new Percy(driver);
42
+ percy.snapshot("Your snapshot name");
43
+ Example:
44
+ \`\`\`java
45
+ import org.openqa.selenium.WebDriver;
46
+ import org.openqa.selenium.chrome.ChromeDriver;
47
+ import io.percy.selenium.Percy;
48
+
49
+ public class PercyExample {
50
+ public static void main(String[] args) {
51
+ WebDriver driver = new ChromeDriver();
52
+ driver.get("http://localhost:8000");
53
+ Percy percy = new Percy(driver);
54
+ percy.snapshot("Home page");
55
+ driver.quit();
56
+ }
57
+ }
58
+ \`\`\``;
59
+ export const rubyInstructionsSnapshot = `
60
+ - Require the Percy snapshot helper:
61
+ require 'percy'
62
+ - In your test, take snapshots like this:
63
+ Percy.snapshot(page, 'Your snapshot name')
64
+
65
+ Example:
66
+ \`\`\`ruby
67
+ require 'selenium-webdriver'
68
+ require 'percy'
69
+
70
+ driver = Selenium::WebDriver.for :chrome
71
+ driver.get('http://localhost:8000')
72
+ Percy.snapshot(driver, 'Your snapshot name')
73
+ driver.quit
74
+ \`\`\`
75
+ `;
76
+ export const rubyCapybaraInstructionsSnapshot = `
77
+ - In your test setup file, require percy/capybara:
78
+ require 'percy/capybara'
79
+ - In your test, take snapshots like this:
80
+ page.percy_snapshot('Capybara snapshot')
81
+
82
+ Example:
83
+ \`\`\`ruby
84
+ require 'percy/capybara'
85
+
86
+ describe 'my feature', type: :feature do
87
+ it 'renders the page' do
88
+ visit 'https://example.com'
89
+ page.percy_snapshot('Capybara snapshot')
90
+ end
91
+ end
92
+ \`\`\`
93
+
94
+ - The snapshot method arguments are:
95
+ page.percy_snapshot(name[, options])
96
+ name - The snapshot name; must be unique to each snapshot; defaults to the test title
97
+ options - See per-snapshot configuration options
98
+ `;
99
+ export const csharpInstructionsSnapshot = `
100
+ - Import the Percy snapshot helper:
101
+ using PercyIO.Selenium;
102
+ - In your test, take snapshots like this:
103
+ Percy.Snapshot(driver,"Your snapshot name");
104
+
105
+ Example:
106
+ \`\`\`csharp
107
+ using OpenQA.Selenium;
108
+ using OpenQA.Selenium.Chrome;
109
+ using PercyIO.Selenium;
110
+
111
+ class PercyExample
112
+ {
113
+ static void Main()
114
+ {
115
+ IWebDriver driver = new ChromeDriver();
116
+ driver.Navigate().GoToUrl("http://localhost:8000");
117
+ Percy.Snapshot(driver,"Empty Todo State");
118
+ driver.Quit();
119
+ }
120
+ }
121
+ \`\`\`
122
+ `;
123
+ export const javaPlaywrightInstructionsSnapshot = `
124
+ - Import the Percy library and use the snapshot method:
125
+ percy.snapshot("snapshot_1");
126
+ - You can also pass options:
127
+ Map<String, Object> options = new HashMap<>();
128
+ options.put("testCase", "Should add product to cart");
129
+ percy.snapshot("snapshot_2", options);
130
+
131
+ Example:
132
+ \`\`\`java
133
+ import com.microsoft.playwright.*;
134
+ import io.percy.playwright.*;
135
+
136
+ public class PercyPlaywrightExample {
137
+ public static void main(String[] args) {
138
+ try (Playwright playwright = Playwright.create()) {
139
+ Browser browser = playwright.chromium().launch();
140
+ Page page = browser.newPage();
141
+ Percy percy = new Percy(page);
142
+
143
+ page.navigate("http://localhost:8000");
144
+ percy.snapshot("Home page");
145
+
146
+ // ... more test steps ...
147
+ percy.snapshot("After login");
148
+
149
+ browser.close();
150
+ }
151
+ }
152
+ }
153
+ \`\`\`
154
+ `;
155
+ export const nodejsPlaywrightInstructionsSnapshot = `
156
+ - Import the Percy snapshot helper:
157
+ const percySnapshot = require('@percy/playwright');
158
+ - In your test, take snapshots like this:
159
+ await percySnapshot(page, "Your snapshot name");
160
+
161
+ Example:
162
+ \`\`\`javascript
163
+ const { chromium } = require('playwright');
164
+ const percySnapshot = require('@percy/playwright');
165
+
166
+ (async () => {
167
+ const browser = await chromium.launch();
168
+ const page = await browser.newPage();
169
+ await page.goto('http://example.com/', { waitUntil: 'networkidle' });
170
+ await percySnapshot(page, 'Example Site');
171
+ await browser.close();
172
+ })();
173
+ \`\`\`
174
+ `;
175
+ export const nodejsWebdriverioInstructionsSnapshot = `
176
+ - Import the Percy snapshot helper:
177
+ const percySnapshot = require('@percy/selenium-webdriver');
178
+ - In your test, take snapshots like this:
179
+ await percySnapshot(driver, "Your snapshot name");
180
+
181
+ Example:
182
+ \`\`\`javascript
183
+ const { remote } = require('webdriverio');
184
+ const percySnapshot = require('@percy/selenium-webdriver');
185
+
186
+ (async () => {
187
+ const browser = await remote({
188
+ logLevel: 'error',
189
+ capabilities: { browserName: 'chrome' }
190
+ });
191
+
192
+ await browser.url('https://example.com');
193
+ await percySnapshot(browser, 'WebdriverIO example');
194
+ await browser.deleteSession();
195
+ })();
196
+ \`\`\`
197
+ `;
198
+ export const nodejsEmberInstructionsSnapshot = `
199
+ - Import the Percy snapshot helper:
200
+ import percySnapshot from '@percy/ember';
201
+ - In your test, take snapshots like this:
202
+ await percySnapshot('My Snapshot');
203
+
204
+ Example:
205
+ \`\`\`javascript
206
+ import percySnapshot from '@percy/ember';
207
+ describe('My ppp', () => {
208
+ // ...app setup
209
+ it('about page should look good', async () => {
210
+ await visit('/about');
211
+ await percySnapshot('My Snapshot');
212
+ });
213
+ });
214
+ \`\`\`
215
+
216
+ - The snapshot method arguments are:
217
+ percySnapshot(name[, options])
218
+ name - The snapshot name; must be unique to each snapshot; defaults to the test title
219
+ options - See per-snapshot configuration options
220
+ `;
221
+ export const nodejsCypressInstructionsSnapshot = `
222
+ - Import the Percy snapshot helper in your cypress/support/e2e.js file:
223
+ import '@percy/cypress';
224
+ - If you’re using TypeScript, include "types": ["cypress", "@percy/cypress"] in your tsconfig.json file.
225
+ - In your test, take snapshots like this:
226
+ cy.percySnapshot();
227
+
228
+ Example:
229
+ \`\`\`javascript
230
+ import '@percy/cypress';
231
+
232
+ describe('Integration test with visual testing', function() {
233
+ it('Loads the homepage', function() {
234
+ // Load the page or perform any other interactions with the app.
235
+ cy.visit('<URL under test>');
236
+ // Take a snapshot for visual diffing
237
+ cy.percySnapshot();
238
+ });
239
+ });
240
+ \`\`\`
241
+
242
+ - The snapshot method arguments are:
243
+ cy.percySnapshot([name][, options])
244
+ name - The snapshot name; must be unique to each snapshot; defaults to the test title
245
+ options - See per-snapshot configuration options
246
+
247
+ - For example:
248
+ cy.percySnapshot();
249
+ cy.percySnapshot('Homepage test');
250
+ cy.percySnapshot('Homepage responsive test', { widths: [768, 992, 1200] });
251
+ `;
252
+ export const nodejsPuppeteerInstructionsSnapshot = `
253
+ - Import the Percy snapshot helper:
254
+ const percySnapshot = require('@percy/puppeteer');
255
+ - In your test, take snapshots like this:
256
+ await percySnapshot(page, 'Snapshot name');
257
+
258
+ Example:
259
+ \`\`\`javascript
260
+ const puppeteer = require('puppeteer');
261
+ const percySnapshot = require('@percy/puppeteer');
262
+
263
+ describe('Integration test with visual testing', function() {
264
+ it('Loads the homepage', async function() {
265
+ const browser = await puppeteer.launch();
266
+ const page = await browser.newPage();
267
+ await page.goto('https://example.com');
268
+ await percySnapshot(page, this.test.fullTitle());
269
+ await browser.close();
270
+ });
271
+ });
272
+ \`\`\`
273
+
274
+ - The snapshot method arguments are:
275
+ percySnapshot(page, name[, options])
276
+ page (required) - A puppeteer page instance
277
+ name (required) - The snapshot name; must be unique to each snapshot
278
+ options - See per-snapshot configuration options
279
+
280
+ - For example:
281
+ percySnapshot(page, 'Homepage test');
282
+ percySnapshot(page, 'Homepage responsive test', { widths: [768, 992, 1200] });
283
+ `;
284
+ export const nodejsNightmareInstructionsSnapshot = `
285
+ - Import the Percy snapshot helper:
286
+ const Nightmare = require('nightmare');
287
+ const percySnapshot = require('@percy/nightmare');
288
+ - In your test, take snapshots like this:
289
+ .use(percySnapshot('Snapshot name'))
290
+
291
+ Example:
292
+ \`\`\`javascript
293
+ const Nightmare = require('nightmare');
294
+ const percySnapshot = require('@percy/nightmare');
295
+
296
+ Nightmare()
297
+ .goto('http://example.com')
298
+ // ... other actions ...
299
+ .use(percySnapshot('Example Snapshot'))
300
+ // ... more actions ...
301
+ .end()
302
+ .then(() => {
303
+ // ...
304
+ });
305
+ \`\`\`
306
+
307
+ - The snapshot method arguments are:
308
+ percySnapshot(name[, options])
309
+ name (required) - The snapshot name; must be unique to each snapshot
310
+ options - See per-snapshot configuration options
311
+ `;
312
+ export const nodejsNightwatchInstructionsSnapshot = `
313
+ - Import the Percy library and add the path exported by @percy/nightwatch to your Nightwatch configuration’s custom_commands_path property:
314
+ const percy = require('@percy/nightwatch');
315
+ module.exports = {
316
+ // ...
317
+ custom_commands_path: [percy.path],
318
+ // ...
319
+ };
320
+ - In your test, take snapshots like this:
321
+ browser.percySnapshot('Snapshot name');
322
+
323
+ Example:
324
+ \`\`\`javascript
325
+ const percy = require('@percy/nightwatch');
326
+ module.exports = {
327
+ // ...
328
+ custom_commands_path: [percy.path],
329
+ // ...
330
+ };
331
+
332
+ // Example test
333
+ module.exports = {
334
+ 'Snapshots pages': function(browser) {
335
+ browser
336
+ .url('http://example.com')
337
+ .assert.containsText('h1', 'Example Domain')
338
+ .percySnapshot('Example snapshot');
339
+ browser
340
+ .url('http://google.com')
341
+ .assert.elementPresent('img[alt="Google"]')
342
+ .percySnapshot('Google homepage');
343
+ browser.end();
344
+ }
345
+ };
346
+ \`\`\`
347
+
348
+ - The snapshot method arguments are:
349
+ percySnapshot([name][, options])
350
+ name (required) - The snapshot name; must be unique to each snapshot
351
+ options - See per-snapshot configuration options
352
+ `;
353
+ export const nodejsProtractorInstructionsSnapshot = `
354
+ - Import the Percy snapshot helper:
355
+ import percySnapshot from '@percy/protractor';
356
+ - In your test, take snapshots like this:
357
+ await percySnapshot('Snapshot name');
358
+ // or
359
+ await percySnapshot(browser, 'Snapshot name');
360
+
361
+ Example:
362
+ \`\`\`javascript
363
+ import percySnapshot from '@percy/protractor';
364
+ describe('angularjs homepage', function() {
365
+ it('should greet the named user', async function() {
366
+ await browser.get('https://www.angularjs.org');
367
+ await percySnapshot('AngularJS homepage');
368
+ await element(by.model('yourName')).sendKeys('Percy');
369
+ var greeting = element(by.binding('yourName'));
370
+ expect(await greeting.getText()).toEqual('Hello Percy!');
371
+ await percySnapshot('AngularJS homepage greeting');
372
+ });
373
+ });
374
+ \`\`\`
375
+
376
+ - The snapshot method arguments are:
377
+ percySnapshot(name[, options])
378
+ Standalone mode:
379
+ percySnapshot(browser, name[, options])
380
+ browser (required) - The Protractor browser object
381
+ name (required) - The snapshot name; must be unique to each snapshot
382
+ options - See per-snapshot configuration options
383
+ `;
384
+ export const nodejsTestcafeInstructionsSnapshot = `
385
+ - Import the Percy snapshot helper:
386
+ import percySnapshot from '@percy/testcafe';
387
+ - In your test, take snapshots like this:
388
+ await percySnapshot(t, 'Snapshot name');
389
+
390
+ Example:
391
+ \`\`\`javascript
392
+ import percySnapshot from '@percy/testcafe';
393
+ fixture('MyFixture')
394
+ .page('https://devexpress.github.io/testcafe/example');
395
+ test('Test1', async t => {
396
+ await t.typeText('#developer-name', 'John Doe');
397
+ await percySnapshot(t, 'TestCafe Example');
398
+ });
399
+ \`\`\`
400
+
401
+ - The snapshot method arguments are:
402
+ percySnapshot(t, name[, options])
403
+ t (required) - The test controller instance passed from test
404
+ name (required) - The snapshot name; must be unique to each snapshot
405
+ options - See per-snapshot configuration options
406
+ `;
407
+ export const nodejsGatsbyInstructionsSnapshot = `
408
+ - Add the Percy plugin to your gatsby-config.js file:
409
+ module.exports = {
410
+ plugins: [\`gatsby-plugin-percy\`]
411
+ }
412
+
413
+ - The plugin will take snapshots of discovered pages during the build process.
414
+
415
+ - Example gatsby-config.js with options:
416
+ \`\`\`javascript
417
+ module.exports = {
418
+ plugins: [{
419
+ resolve: \`gatsby-plugin-percy\`,
420
+ options: {
421
+ // gatsby specific options
422
+ query: \`{
423
+ allSitePage { nodes { path } }
424
+ allOtherPage { nodes { path } }
425
+ }\`,
426
+ resolvePages: ({
427
+ allSitePage: { nodes: allPages },
428
+ allOtherPage: { nodes: otherPages }
429
+ }) => {
430
+ return [...allPages, ...otherPages]
431
+ .map(({ path }) => path);
432
+ },
433
+ // percy static snapshot options
434
+ exclude: [
435
+ '/dev-404-page/',
436
+ '/offline-plugin-app-shell-fallback/'
437
+ ],
438
+ overrides: [{
439
+ include: '/foobar/',
440
+ waitForSelector: '.done-loading',
441
+ additionalSnapshots: [{
442
+ suffix: ' - after btn click',
443
+ execute: () => document.querySelector('.btn').click()
444
+ }]
445
+ }]
446
+ }
447
+ }]
448
+ }
449
+ \`\`\`
450
+ `;
451
+ export const nodejsStorybookInstructionsSnapshot = `
452
+ - Add Percy parameters to your stories to customize snapshots:
453
+ \`\`\`js
454
+ MyStory.parameters = {
455
+ percy: {
456
+ name: 'My snapshot',
457
+ additionalSnapshots: [
458
+ { prefix: '[Dark mode] ', args: { colorScheme: 'dark' } },
459
+ { suffix: ' with globals', globals: { textDirection: 'rtl' } },
460
+ { name: 'Search snapshot', queryParams: { search: 'foobar' } }
461
+ ]
462
+ }
463
+ };
464
+ \`\`\`
465
+ - Use argument names and values defined in your codebase.
466
+ `;
467
+ export const pythonPlaywrightInstructionsSnapshot = `
468
+ - Import the Percy snapshot helper and use the snapshot method:
469
+ percy_snapshot(page, name="Your snapshot name")
470
+ - You can also use:
471
+ percy_screenshot(page, name="Your snapshot name", options={})
472
+
473
+ Example:
474
+ \`\`\`python
475
+ from playwright.sync_api import sync_playwright
476
+ from percy import percy_snapshot
477
+
478
+ with sync_playwright() as p:
479
+ browser = p.chromium.launch()
480
+ page = browser.new_page()
481
+ page.goto("http://localhost:8000")
482
+ percy_snapshot(page, name="Home page")
483
+
484
+ # ... more test steps ...
485
+ percy_snapshot(page, name="After login")
486
+
487
+ browser.close()
488
+ \`\`\`
489
+ `;
490
+ export const csharpPlaywrightInstructionsSnapshot = `
491
+ - Import the Percy snapshot helper and use the snapshot method:
492
+ Percy.Snapshot(page, "Your snapshot name");
493
+ - You can also pass options:
494
+ Percy.Snapshot(page, "Your snapshot name", options);
495
+
496
+ Example:
497
+ \`\`\`csharp
498
+ using Microsoft.Playwright;
499
+ using PercyIO.Playwright;
500
+
501
+ class PercyPlaywrightExample
502
+ {
503
+ public static async Task Main()
504
+ {
505
+ using var playwright = await Playwright.CreateAsync();
506
+ var browser = await playwright.Chromium.LaunchAsync();
507
+ var page = await browser.NewPageAsync();
508
+
509
+ await page.GotoAsync("http://localhost:8000");
510
+ Percy.Snapshot(page, "Home page");
511
+
512
+ // ... more test steps ...
513
+ Percy.Snapshot(page, "After login");
514
+
515
+ await browser.CloseAsync();
516
+ }
517
+ }
518
+ \`\`\`
519
+ `;
520
+ export const pythonInstructions = `
521
+ Install Percy dependencies
522
+ - Install Percy CLI:
523
+ npm install --save-dev @percy/cli
524
+ - Install Percy Selenium Python package:
525
+ pip install percy-selenium
526
+ If faced any issue create a virtual environment and proceed.
527
+ Update your Python Selenium script
528
+ ${PERCY_SNAPSHOT_INSTRUCTION}
529
+ ${pythonInstructionsSnapshot}
530
+
531
+ ---STEP---
532
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- python tests.py').
533
+ ${percyReviewSnapshotsStep}
534
+ `;
535
+ export const nodejsInstructions = `
536
+ ---STEP---
537
+ Install Percy dependencies
538
+ - Install Percy CLI:
539
+ npm install --save-dev @percy/cli
540
+ - Install Percy SDK for Node.js:
541
+ npm install @percy/selenium-webdriver
542
+ ---STEP---
543
+ Update your Node.js Selenium script
544
+ ${PERCY_SNAPSHOT_INSTRUCTION}
545
+ ${nodejsInstructionsSnapshot}
546
+
547
+ ---STEP---
548
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- node script.js').
549
+
550
+ ${percyReviewSnapshotsStep}
551
+ `;
552
+ export const javaInstructions = `
553
+ ---STEP---
554
+ Add Percy dependencies to your project
555
+ - For Maven, add to your pom.xml:
556
+ <dependency>
557
+ <groupId>io.percy</groupId>
558
+ <artifactId>percy-java-selenium</artifactId>
559
+ <version>1.0.0</version>
560
+ </dependency>
561
+ - For Gradle, add to your build.gradle:
562
+ implementation 'io.percy:percy-java-selenium:1.0.0'
563
+ - For CLI usage, install Percy CLI:
564
+ npm install --save-dev @percy/cli
565
+
566
+ ---STEP---
567
+ Update your Java Selenium test
568
+ ${PERCY_SNAPSHOT_INSTRUCTION}
569
+ ${javaInstructionsSnapshot}
570
+
571
+ ---STEP---
572
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- mvn test').
573
+
574
+ ${percyReviewSnapshotsStep}
575
+ `;
576
+ export const rubyInstructions = `
577
+ ---STEP---
578
+ Install Percy dependencies
579
+ - Install Percy CLI:
580
+ npm install --save-dev @percy/cli
581
+ - Install Percy Ruby Selenium gem:
582
+ gem install percy-selenium
583
+
584
+ ---STEP---
585
+ Update your Ruby Selenium test
586
+ ${PERCY_SNAPSHOT_INSTRUCTION}
587
+ ${rubyInstructionsSnapshot}
588
+
589
+ ---STEP---
590
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- bundle exec rspec').
591
+
592
+ ${percyReviewSnapshotsStep}
593
+ `;
594
+ // Percy Capybara instructions for Ruby
595
+ export const rubyCapybaraInstructions = `
596
+ ---STEP---
597
+ Install Percy dependencies
598
+ - Install Percy CLI:
599
+ npm install --save-dev @percy/cli
600
+ - Install Percy Capybara gem:
601
+ gem install percy-capybara
602
+
603
+ ---STEP---
604
+ Update your Capybara or Rails test script
605
+ ${PERCY_SNAPSHOT_INSTRUCTION}
606
+ ${rubyCapybaraInstructionsSnapshot}
607
+
608
+ ---STEP---
609
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- bundle exec rspec').
610
+
611
+ ${percyReviewSnapshotsStep}
612
+ `;
613
+ export const csharpInstructions = `
614
+ Install Percy CLI by running the following command:
615
+ npm install --save-dev @percy/cli
616
+
617
+ ---STEP---
618
+ Add Percy dependencies to your project
619
+ - Add the Percy .NET Selenium NuGet package:
620
+ dotnet add package PercyIO.Selenium
621
+
622
+ ---STEP---
623
+ Update your C# Selenium test
624
+ ${PERCY_SNAPSHOT_INSTRUCTION}
625
+ ${csharpInstructionsSnapshot}
626
+
627
+ ---STEP---
628
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- dotnet test').
629
+
630
+ ${percyReviewSnapshotsStep}
631
+ `;
632
+ export const javaPlaywrightInstructions = `
633
+ Install Percy dependencies
634
+ - For Maven, add to your pom.xml:
635
+ <dependency>
636
+ <groupId>io.percy</groupId>
637
+ <artifactId>percy-playwright-java</artifactId>
638
+ <version>1.0.0</version>
639
+ </dependency>
640
+
641
+ ---STEP---
642
+ Update your Java Playwright test
643
+ ${PERCY_SNAPSHOT_INSTRUCTION}
644
+ ${javaPlaywrightInstructionsSnapshot}
645
+
646
+ ---STEP---
647
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g. npx percy exec -- <command to run the test script file>).
648
+
649
+ ${percyReviewSnapshotsStep}
650
+ `;
651
+ export const nodejsPlaywrightInstructions = `
652
+ Install Percy dependencies
653
+ - Install Percy Playwright SDK:
654
+ npm install @percy/playwright
655
+
656
+ ---STEP---
657
+ Update your Playwright JavaScript test
658
+ ${PERCY_SNAPSHOT_INSTRUCTION}
659
+ ${nodejsPlaywrightInstructionsSnapshot}
660
+
661
+ ---STEP---
662
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., npx percy exec -- <command to run the test script file>).
663
+ ${percyReviewSnapshotsStep}
664
+ `;
665
+ // Percy WebdriverIO instructions for JavaScript
666
+ export const nodejsWebdriverioInstructions = `
667
+ ---STEP---
668
+ Install Percy dependencies
669
+ - Install Percy CLI:
670
+ npm install --save-dev @percy/cli
671
+ - Install Percy Selenium Webdriver package:
672
+ npm install --save-dev @percy/selenium-webdriver
673
+
674
+ ---STEP---
675
+ Update your WebdriverIO test script
676
+ ${PERCY_SNAPSHOT_INSTRUCTION}
677
+ ${nodejsWebdriverioInstructionsSnapshot}
678
+
679
+ ---STEP---
680
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- wdio run wdio.conf.js').
681
+
682
+ ${percyReviewSnapshotsStep}
683
+ `;
684
+ // Percy Ember instructions for JavaScript
685
+ export const nodejsEmberInstructions = `
686
+ ---STEP---
687
+ Install Percy dependencies
688
+ - Install Percy CLI and Ember SDK:
689
+ npm install --save-dev @percy/cli @percy/ember
690
+
691
+ ---STEP---
692
+ Update your Ember test script
693
+ ${PERCY_SNAPSHOT_INSTRUCTION}
694
+ ${nodejsEmberInstructionsSnapshot}
695
+
696
+ ---STEP---
697
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- ember test').
698
+
699
+ ${percyReviewSnapshotsStep}
700
+ `;
701
+ // Percy Cypress instructions for JavaScript
702
+ export const nodejsCypressInstructions = `
703
+ ---STEP---
704
+ Install Percy dependencies
705
+ - Install Percy CLI and Cypress SDK:
706
+ npm install --save-dev @percy/cli @percy/cypress
707
+
708
+ ---STEP---
709
+ Update your Cypress test script
710
+ ${PERCY_SNAPSHOT_INSTRUCTION}
711
+ ${nodejsCypressInstructionsSnapshot}
712
+
713
+ ---STEP---
714
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- cypress run').
715
+
716
+ ${percyReviewSnapshotsStep}
717
+ `;
718
+ // Percy Puppeteer instructions for JavaScript
719
+ export const nodejsPuppeteerInstructions = `
720
+ ---STEP---
721
+ Install Percy dependencies
722
+ - Install Percy CLI and Puppeteer SDK:
723
+ npm install --save-dev @percy/cli @percy/puppeteer
724
+
725
+ ---STEP---
726
+ Update your Puppeteer test script
727
+ ${PERCY_SNAPSHOT_INSTRUCTION}
728
+ ${nodejsPuppeteerInstructionsSnapshot}
729
+
730
+ ---STEP---
731
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- <command to run the test script file>').
732
+
733
+ ${percyReviewSnapshotsStep}
734
+ `;
735
+ // Percy Nightmare instructions for JavaScript
736
+ export const nodejsNightmareInstructions = `
737
+ ---STEP---
738
+ Install Percy dependencies
739
+ - Install Percy CLI and Nightmare SDK:
740
+ npm install --save-dev @percy/cli @percy/nightmare
741
+
742
+ ---STEP---
743
+ Update your Nightmare test script
744
+ ${PERCY_SNAPSHOT_INSTRUCTION}
745
+ ${nodejsNightmareInstructionsSnapshot}
746
+
747
+ ---STEP---
748
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- node script.js').
749
+
750
+ ${percyReviewSnapshotsStep}
751
+ `;
752
+ // Percy Nightwatch instructions for JavaScript
753
+ export const nodejsNightwatchInstructions = `
754
+ ---STEP---
755
+ Install Percy dependencies
756
+ - Install Percy CLI and Nightwatch SDK:
757
+ npm install --save-dev @percy/cli @percy/nightwatch
758
+
759
+ ---STEP---
760
+ Update your Nightwatch configuration and test script
761
+ ${PERCY_SNAPSHOT_INSTRUCTION}
762
+ ${nodejsNightwatchInstructionsSnapshot}
763
+
764
+ ---STEP---
765
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- nightwatch').
766
+
767
+ ${percyReviewSnapshotsStep}
768
+ `;
769
+ // Percy Protractor instructions for JavaScript
770
+ export const nodejsProtractorInstructions = `
771
+ ---STEP---
772
+ Install Percy dependencies
773
+ - Install Percy CLI and Protractor SDK:
774
+ npm install --save-dev @percy/cli @percy/protractor
775
+
776
+ ---STEP---
777
+ Update your Protractor test script
778
+ ${PERCY_SNAPSHOT_INSTRUCTION}
779
+ ${nodejsProtractorInstructionsSnapshot}
780
+
781
+ ---STEP---
782
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- protractor conf.js').
783
+
784
+ ${percyReviewSnapshotsStep}
785
+ `;
786
+ // Percy TestCafe instructions for JavaScript
787
+ export const nodejsTestcafeInstructions = `
788
+ ---STEP---
789
+ Install Percy dependencies
790
+ - Install Percy CLI and TestCafe SDK:
791
+ npm install --save-dev @percy/cli @percy/testcafe
792
+
793
+ ---STEP---
794
+ Update your TestCafe test script
795
+ ${PERCY_SNAPSHOT_INSTRUCTION}
796
+ ${nodejsTestcafeInstructionsSnapshot}
797
+
798
+ ---STEP---
799
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- testcafe chrome:headless tests').
800
+ ${percyReviewSnapshotsStep}
801
+ `;
802
+ // Percy Gatsby instructions for JavaScript
803
+ export const nodejsGatsbyInstructions = `
804
+ ---STEP---
805
+ Install Percy dependencies
806
+ - Install Percy CLI and Gatsby plugin:
807
+ npm install --save @percy/cli gatsby-plugin-percy
808
+
809
+ ---STEP---
810
+ Update your Gatsby configuration
811
+ ${PERCY_SNAPSHOT_INSTRUCTION}
812
+ ${nodejsGatsbyInstructionsSnapshot}
813
+
814
+ ---STEP---
815
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g., 'npx percy exec -- gatsby build').
816
+ ${percyReviewSnapshotsStep}
817
+ `;
818
+ // Percy Storybook instructions for JavaScript
819
+ export const nodejsStorybookInstructions = `
820
+ ---STEP---
821
+ Install Percy dependencies
822
+ - Install Percy CLI and Storybook SDK:
823
+ npm install --save-dev @percy/cli @percy/storybook
824
+
825
+ ---STEP---
826
+ Update your Storybook stories
827
+ ${PERCY_SNAPSHOT_INSTRUCTION}
828
+ ${nodejsStorybookInstructionsSnapshot}
829
+
830
+ ---STEP---
831
+ Run Percy with your Storybook
832
+ - With a static Storybook build:
833
+ percy storybook ./storybook-build
834
+ - With a local or live Storybook URL:
835
+ percy storybook http://localhost:9009
836
+ percy storybook https://storybook.foobar.com
837
+ - Automatically run start-storybook:
838
+ Run this scan using tool runPercyScan with 'npx percy exec -- percy storybook:start --port=9009'.
839
+
840
+ ${percyReviewSnapshotsStep}
841
+ `;
842
+ export const pythonPlaywrightInstructions = `
843
+ ---STEP---
844
+ Create a Percy project
845
+ - Sign in to Percy and create a project of type "Web". Name the project and note the generated token.
846
+
847
+ ---STEP---
848
+ Set the project token as an environment variable
849
+ - On macOS/Linux:
850
+ export PERCY_TOKEN="<your token here>"
851
+ - On Windows PowerShell:
852
+ $env:PERCY_TOKEN="<your token here>"
853
+ - On Windows CMD:
854
+ set PERCY_TOKEN=<your token here>
855
+
856
+ ---STEP---
857
+ Install Percy dependencies
858
+ - Install Percy Playwright SDK:
859
+ pip install percy-playwright
860
+
861
+ ---STEP---
862
+ Update your Playwright Python test
863
+ ${PERCY_SNAPSHOT_INSTRUCTION}
864
+ ${pythonPlaywrightInstructionsSnapshot}
865
+
866
+ ---STEP---
867
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g. npx percy exec -- <command to run the test script file>).
868
+ ${percyReviewSnapshotsStep}
869
+ `;
870
+ export const csharpPlaywrightInstructions = `
871
+ Install Percy dependencies
872
+ - Add the Percy Playwright NuGet package:
873
+ <PackageReference Include="PercyIO.Playwright" Version="1.0.0" />
874
+
875
+ ---STEP---
876
+ Update your Playwright .NET test
877
+ ${PERCY_SNAPSHOT_INSTRUCTION}
878
+ ${csharpPlaywrightInstructionsSnapshot}
879
+
880
+ ---STEP---
881
+ To run the Percy build, call the tool runPercyScan with the appropriate test command (e.g. npx percy exec -- <command to run the test script file>).
882
+ ${percyReviewSnapshotsStep}
883
+ `;