@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.
Files changed (113) hide show
  1. package/README.md +227 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +1 -0
  4. package/dist/lib/device-cache.d.ts +1 -0
  5. package/dist/lib/device-cache.js +28 -0
  6. package/dist/lib/inmemory-store.d.ts +1 -0
  7. package/dist/lib/inmemory-store.js +1 -0
  8. package/dist/lib/instrumentation.js +2 -0
  9. package/dist/oninitialized.js +4 -1
  10. package/dist/server-factory.js +3 -1
  11. package/dist/tools/accessibility.js +238 -78
  12. package/dist/tools/accessiblity-utils/auth-config.d.ts +39 -0
  13. package/dist/tools/accessiblity-utils/auth-config.js +125 -0
  14. package/dist/tools/accessiblity-utils/scanner.d.ts +1 -1
  15. package/dist/tools/accessiblity-utils/scanner.js +2 -1
  16. package/dist/tools/add-percy-snapshots.d.ts +5 -0
  17. package/dist/tools/add-percy-snapshots.js +17 -0
  18. package/dist/tools/appautomate-utils/appautomate.d.ts +2 -1
  19. package/dist/tools/appautomate-utils/appautomate.js +12 -9
  20. package/dist/tools/appautomate.js +56 -7
  21. package/dist/tools/applive-utils/start-session.d.ts +2 -1
  22. package/dist/tools/applive-utils/start-session.js +17 -6
  23. package/dist/tools/applive.d.ts +2 -1
  24. package/dist/tools/applive.js +21 -17
  25. package/dist/tools/bstack-sdk.d.ts +2 -15
  26. package/dist/tools/bstack-sdk.js +7 -124
  27. package/dist/tools/list-test-files.d.ts +2 -0
  28. package/dist/tools/list-test-files.js +33 -0
  29. package/dist/tools/percy-sdk.d.ts +4 -0
  30. package/dist/tools/percy-sdk.js +88 -0
  31. package/dist/tools/percy-snapshot-utils/constants.d.ts +16 -0
  32. package/dist/tools/percy-snapshot-utils/constants.js +500 -0
  33. package/dist/tools/percy-snapshot-utils/detect-test-files.d.ts +10 -0
  34. package/dist/tools/percy-snapshot-utils/detect-test-files.js +194 -0
  35. package/dist/tools/percy-snapshot-utils/types.d.ts +15 -0
  36. package/dist/tools/percy-snapshot-utils/utils.d.ts +4 -0
  37. package/dist/tools/percy-snapshot-utils/utils.js +30 -0
  38. package/dist/tools/sdk-utils/{commands.d.ts → bstack/commands.d.ts} +1 -1
  39. package/dist/tools/sdk-utils/bstack/commands.js +88 -0
  40. package/dist/tools/sdk-utils/bstack/configUtils.d.ts +4 -0
  41. package/dist/tools/sdk-utils/bstack/configUtils.js +66 -0
  42. package/dist/tools/sdk-utils/bstack/constants.d.ts +58 -0
  43. package/dist/tools/sdk-utils/{constants.js → bstack/constants.js} +128 -76
  44. package/dist/tools/sdk-utils/{constants.d.ts → bstack/frameworks.d.ts} +1 -1
  45. package/dist/tools/sdk-utils/bstack/frameworks.js +57 -0
  46. package/dist/tools/sdk-utils/bstack/index.d.ts +4 -0
  47. package/dist/tools/sdk-utils/bstack/index.js +5 -0
  48. package/dist/tools/sdk-utils/bstack/sdkHandler.d.ts +4 -0
  49. package/dist/tools/sdk-utils/bstack/sdkHandler.js +74 -0
  50. package/dist/tools/sdk-utils/common/constants.d.ts +10 -0
  51. package/dist/tools/sdk-utils/common/constants.js +86 -0
  52. package/dist/tools/sdk-utils/common/formatUtils.d.ts +5 -0
  53. package/dist/tools/sdk-utils/common/formatUtils.js +27 -0
  54. package/dist/tools/sdk-utils/common/index.d.ts +3 -0
  55. package/dist/tools/sdk-utils/common/index.js +4 -0
  56. package/dist/tools/sdk-utils/common/instructionUtils.d.ts +8 -0
  57. package/dist/tools/sdk-utils/common/instructionUtils.js +20 -0
  58. package/dist/tools/sdk-utils/common/schema.d.ts +61 -0
  59. package/dist/tools/sdk-utils/common/schema.js +28 -0
  60. package/dist/tools/sdk-utils/common/types.d.ts +66 -0
  61. package/dist/tools/sdk-utils/common/types.js +50 -0
  62. package/dist/tools/sdk-utils/common/utils.d.ts +25 -0
  63. package/dist/tools/sdk-utils/common/utils.js +84 -0
  64. package/dist/tools/sdk-utils/handler.d.ts +5 -0
  65. package/dist/tools/sdk-utils/handler.js +144 -0
  66. package/dist/tools/sdk-utils/percy-automate/constants.d.ts +11 -0
  67. package/dist/tools/sdk-utils/percy-automate/constants.js +365 -0
  68. package/dist/tools/sdk-utils/percy-automate/frameworks.d.ts +8 -0
  69. package/dist/tools/sdk-utils/percy-automate/frameworks.js +50 -0
  70. package/dist/tools/sdk-utils/percy-automate/handler.d.ts +3 -0
  71. package/dist/tools/sdk-utils/percy-automate/handler.js +30 -0
  72. package/dist/tools/sdk-utils/percy-automate/index.d.ts +1 -0
  73. package/dist/tools/sdk-utils/percy-automate/index.js +2 -0
  74. package/dist/tools/sdk-utils/percy-automate/types.d.ts +13 -0
  75. package/dist/tools/sdk-utils/percy-automate/types.js +1 -0
  76. package/dist/tools/sdk-utils/percy-bstack/constants.d.ts +4 -0
  77. package/dist/tools/sdk-utils/{percy → percy-bstack}/constants.js +13 -39
  78. package/dist/tools/sdk-utils/percy-bstack/frameworks.d.ts +2 -0
  79. package/dist/tools/sdk-utils/percy-bstack/frameworks.js +27 -0
  80. package/dist/tools/sdk-utils/percy-bstack/handler.d.ts +4 -0
  81. package/dist/tools/sdk-utils/percy-bstack/handler.js +99 -0
  82. package/dist/tools/sdk-utils/percy-bstack/index.d.ts +4 -0
  83. package/dist/tools/sdk-utils/percy-bstack/index.js +4 -0
  84. package/dist/tools/sdk-utils/percy-bstack/instructions.d.ts +7 -0
  85. package/dist/tools/sdk-utils/{percy → percy-bstack}/instructions.js +5 -9
  86. package/dist/tools/sdk-utils/percy-bstack/types.d.ts +13 -0
  87. package/dist/tools/sdk-utils/percy-bstack/types.js +5 -0
  88. package/dist/tools/sdk-utils/percy-web/constants.d.ts +41 -0
  89. package/dist/tools/sdk-utils/percy-web/constants.js +941 -0
  90. package/dist/tools/sdk-utils/percy-web/fetchPercyToken.d.ts +4 -0
  91. package/dist/tools/sdk-utils/percy-web/fetchPercyToken.js +28 -0
  92. package/dist/tools/sdk-utils/percy-web/frameworks.d.ts +7 -0
  93. package/dist/tools/sdk-utils/percy-web/frameworks.js +103 -0
  94. package/dist/tools/sdk-utils/percy-web/handler.d.ts +4 -0
  95. package/dist/tools/sdk-utils/percy-web/handler.js +27 -0
  96. package/dist/tools/sdk-utils/percy-web/index.d.ts +4 -0
  97. package/dist/tools/sdk-utils/percy-web/index.js +4 -0
  98. package/dist/tools/sdk-utils/percy-web/types.d.ts +12 -0
  99. package/dist/tools/sdk-utils/percy-web/types.js +1 -0
  100. package/dist/tools/sdk-utils/types.d.ts +2 -1
  101. package/dist/tools/sdk-utils/types.js +1 -0
  102. package/dist/tools/testmanagement-utils/create-testcase.d.ts +4 -0
  103. package/dist/tools/testmanagement-utils/create-testcase.js +6 -0
  104. package/package.json +1 -1
  105. package/dist/tools/sdk-utils/commands.js +0 -65
  106. package/dist/tools/sdk-utils/instructions.d.ts +0 -6
  107. package/dist/tools/sdk-utils/instructions.js +0 -99
  108. package/dist/tools/sdk-utils/percy/constants.d.ts +0 -3
  109. package/dist/tools/sdk-utils/percy/instructions.d.ts +0 -10
  110. package/dist/tools/sdk-utils/percy/types.d.ts +0 -5
  111. /package/dist/tools/{getFailureLogs.d.ts → get-failure-logs.d.ts} +0 -0
  112. /package/dist/tools/{getFailureLogs.js → get-failure-logs.js} +0 -0
  113. /package/dist/tools/{sdk-utils/percy → percy-snapshot-utils}/types.js +0 -0
@@ -0,0 +1,941 @@
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
+
527
+ Update your Python Selenium script
528
+ ${PERCY_SNAPSHOT_INSTRUCTION}
529
+ ${pythonInstructionsSnapshot}
530
+
531
+ Run Percy with your tests
532
+ - Use the following command:
533
+ npx percy exec -- <your command to run tests>
534
+
535
+ Example output:
536
+ [percy] Percy has started!
537
+ [percy] Created build #1: https://percy.io/your-project
538
+ [percy] Snapshot taken "Home page"
539
+ [percy] Finalized build #1: https://percy.io/your-project
540
+ [percy] Done!
541
+
542
+ ${percyReviewSnapshotsStep}
543
+ `;
544
+ export const nodejsInstructions = `
545
+ ---STEP---
546
+ Install Percy dependencies
547
+ - Install Percy CLI:
548
+ npm install --save-dev @percy/cli
549
+ - Install Percy SDK for Node.js:
550
+ npm install @percy/selenium-webdriver
551
+ ---STEP---
552
+ Update your Node.js Selenium script
553
+ ${PERCY_SNAPSHOT_INSTRUCTION}
554
+ ${nodejsInstructionsSnapshot}
555
+
556
+ ---STEP---
557
+ Run Percy with your tests
558
+ - Use the following command:
559
+ npx percy exec -- node scripts/test.js
560
+
561
+ ${percyReviewSnapshotsStep}
562
+ `;
563
+ export const javaInstructions = `
564
+ ---STEP---
565
+ Add Percy dependencies to your project
566
+ - For Maven, add to your pom.xml:
567
+ <dependency>
568
+ <groupId>io.percy</groupId>
569
+ <artifactId>percy-java-selenium</artifactId>
570
+ <version>1.0.0</version>
571
+ </dependency>
572
+ - For Gradle, add to your build.gradle:
573
+ implementation 'io.percy:percy-java-selenium:1.0.0'
574
+ - For CLI usage, install Percy CLI:
575
+ npm install --save-dev @percy/cli
576
+
577
+ ---STEP---
578
+ Update your Java Selenium test
579
+ ${PERCY_SNAPSHOT_INSTRUCTION}
580
+ ${javaInstructionsSnapshot}
581
+
582
+ ---STEP---
583
+ Run Percy with your tests
584
+ - Use the following command:
585
+ npx percy exec -- mvn test
586
+
587
+ ${percyReviewSnapshotsStep}
588
+ `;
589
+ export const rubyInstructions = `
590
+ ---STEP---
591
+ Install Percy dependencies
592
+ - Install Percy CLI:
593
+ npm install --save-dev @percy/cli
594
+ - Install Percy Ruby Selenium gem:
595
+ gem install percy-selenium
596
+
597
+ ---STEP---
598
+ Update your Ruby Selenium test
599
+ ${PERCY_SNAPSHOT_INSTRUCTION}
600
+ ${rubyInstructionsSnapshot}
601
+
602
+ ---STEP---
603
+ Run Percy with your tests
604
+ - Use the following command:
605
+ npx percy exec -- <your command to run tests>
606
+
607
+ ${percyReviewSnapshotsStep}
608
+ `;
609
+ // Percy Capybara instructions for Ruby
610
+ export const rubyCapybaraInstructions = `
611
+ ---STEP---
612
+ Install Percy dependencies
613
+ - Install Percy CLI:
614
+ npm install --save-dev @percy/cli
615
+ - Install Percy Capybara gem:
616
+ gem install percy-capybara
617
+
618
+ ---STEP---
619
+ Update your Capybara or Rails test script
620
+ ${PERCY_SNAPSHOT_INSTRUCTION}
621
+ ${rubyCapybaraInstructionsSnapshot}
622
+
623
+ ---STEP---
624
+ Run Percy with your tests
625
+ - Use the following command:
626
+ npx percy exec -- bundle exec rspec
627
+
628
+ ${percyReviewSnapshotsStep}
629
+ `;
630
+ export const csharpInstructions = `
631
+ Install Percy CLI by running the following command:
632
+ npm install --save-dev @percy/cli
633
+
634
+ ---STEP---
635
+ Add Percy dependencies to your project
636
+ - Add the Percy .NET Selenium NuGet package:
637
+ dotnet add package PercyIO.Selenium
638
+
639
+ ---STEP---
640
+ Update your C# Selenium test
641
+ ${PERCY_SNAPSHOT_INSTRUCTION}
642
+ ${csharpInstructionsSnapshot}
643
+
644
+ Run Percy with your tests
645
+ - Use the following command:
646
+ npx percy exec -- <your command to run tests>
647
+
648
+ ${percyReviewSnapshotsStep}
649
+ `;
650
+ export const javaPlaywrightInstructions = `
651
+ Install Percy dependencies
652
+ - For Maven, add to your pom.xml:
653
+ <dependency>
654
+ <groupId>io.percy</groupId>
655
+ <artifactId>percy-playwright-java</artifactId>
656
+ <version>1.0.0</version>
657
+ </dependency>
658
+
659
+ ---STEP---
660
+ Update your Java Playwright test
661
+ ${PERCY_SNAPSHOT_INSTRUCTION}
662
+ ${javaPlaywrightInstructionsSnapshot}
663
+
664
+ ---STEP---
665
+ Run Percy with your tests
666
+ - Use the following command:
667
+ npx percy exec -- <command to run the test script file>
668
+
669
+ ${percyReviewSnapshotsStep}
670
+ `;
671
+ export const nodejsPlaywrightInstructions = `
672
+ Install Percy dependencies
673
+ - Install Percy Playwright SDK:
674
+ npm install @percy/playwright
675
+
676
+ ---STEP---
677
+ Update your Playwright JavaScript test
678
+ ${PERCY_SNAPSHOT_INSTRUCTION}
679
+ ${nodejsPlaywrightInstructionsSnapshot}
680
+
681
+ ---STEP---
682
+ Run Percy with your tests
683
+ - Use the following command:
684
+ npx percy exec -- <command to run the test script file>
685
+ ${percyReviewSnapshotsStep}
686
+ `;
687
+ // Percy WebdriverIO instructions for JavaScript
688
+ export const nodejsWebdriverioInstructions = `
689
+ ---STEP---
690
+ Install Percy dependencies
691
+ - Install Percy CLI:
692
+ npm install --save-dev @percy/cli
693
+ - Install Percy Selenium Webdriver package:
694
+ npm install --save-dev @percy/selenium-webdriver
695
+
696
+ ---STEP---
697
+ Update your WebdriverIO test script
698
+ ${PERCY_SNAPSHOT_INSTRUCTION}
699
+ ${nodejsWebdriverioInstructionsSnapshot}
700
+
701
+ ---STEP---
702
+ Run Percy with your tests
703
+ - Use the following command:
704
+ npx percy exec -- wdio run wdio.conf.js
705
+
706
+ ${percyReviewSnapshotsStep}
707
+ `;
708
+ // Percy Ember instructions for JavaScript
709
+ export const nodejsEmberInstructions = `
710
+ ---STEP---
711
+ Install Percy dependencies
712
+ - Install Percy CLI and Ember SDK:
713
+ npm install --save-dev @percy/cli @percy/ember
714
+
715
+ ---STEP---
716
+ Update your Ember test script
717
+ ${PERCY_SNAPSHOT_INSTRUCTION}
718
+ ${nodejsEmberInstructionsSnapshot}
719
+
720
+ ---STEP---
721
+ Run Percy with your tests
722
+ - Use the following command:
723
+ npx percy exec -- ember test
724
+
725
+ ${percyReviewSnapshotsStep}
726
+ `;
727
+ // Percy Cypress instructions for JavaScript
728
+ export const nodejsCypressInstructions = `
729
+ ---STEP---
730
+ Install Percy dependencies
731
+ - Install Percy CLI and Cypress SDK:
732
+ npm install --save-dev @percy/cli @percy/cypress
733
+
734
+ ---STEP---
735
+ Update your Cypress test script
736
+ ${PERCY_SNAPSHOT_INSTRUCTION}
737
+ ${nodejsCypressInstructionsSnapshot}
738
+
739
+ ---STEP---
740
+ Run Percy with your tests
741
+ - Use the following command:
742
+ npx percy exec -- cypress run
743
+
744
+ ${percyReviewSnapshotsStep}
745
+ `;
746
+ // Percy Puppeteer instructions for JavaScript
747
+ export const nodejsPuppeteerInstructions = `
748
+ ---STEP---
749
+ Install Percy dependencies
750
+ - Install Percy CLI and Puppeteer SDK:
751
+ npm install --save-dev @percy/cli @percy/puppeteer
752
+
753
+ ---STEP---
754
+ Update your Puppeteer test script
755
+ ${PERCY_SNAPSHOT_INSTRUCTION}
756
+ ${nodejsPuppeteerInstructionsSnapshot}
757
+
758
+ ---STEP---
759
+ Run Percy with your tests
760
+ - Use the following command:
761
+ npx percy exec -- mocha
762
+
763
+ ${percyReviewSnapshotsStep}
764
+ `;
765
+ // Percy Nightmare instructions for JavaScript
766
+ export const nodejsNightmareInstructions = `
767
+ ---STEP---
768
+ Install Percy dependencies
769
+ - Install Percy CLI and Nightmare SDK:
770
+ npm install --save-dev @percy/cli @percy/nightmare
771
+
772
+ ---STEP---
773
+ Update your Nightmare test script
774
+ ${PERCY_SNAPSHOT_INSTRUCTION}
775
+ ${nodejsNightmareInstructionsSnapshot}
776
+
777
+ ---STEP---
778
+ Run Percy with your tests
779
+ - Use the following command:
780
+ npx percy exec -- node script.js
781
+
782
+ ${percyReviewSnapshotsStep}
783
+ `;
784
+ // Percy Nightwatch instructions for JavaScript
785
+ export const nodejsNightwatchInstructions = `
786
+ ---STEP---
787
+ Install Percy dependencies
788
+ - Install Percy CLI and Nightwatch SDK:
789
+ npm install --save-dev @percy/cli @percy/nightwatch
790
+
791
+ ---STEP---
792
+ Update your Nightwatch configuration and test script
793
+ ${PERCY_SNAPSHOT_INSTRUCTION}
794
+ ${nodejsNightwatchInstructionsSnapshot}
795
+
796
+ ---STEP---
797
+ Run Percy with your tests
798
+ - Use the following command:
799
+ npx percy exec -- nightwatch
800
+
801
+ ${percyReviewSnapshotsStep}
802
+ `;
803
+ // Percy Protractor instructions for JavaScript
804
+ export const nodejsProtractorInstructions = `
805
+ ---STEP---
806
+ Install Percy dependencies
807
+ - Install Percy CLI and Protractor SDK:
808
+ npm install --save-dev @percy/cli @percy/protractor
809
+
810
+ ---STEP---
811
+ Update your Protractor test script
812
+ ${PERCY_SNAPSHOT_INSTRUCTION}
813
+ ${nodejsProtractorInstructionsSnapshot}
814
+
815
+ ---STEP---
816
+ Run Percy with your tests
817
+ - Use the following command:
818
+ npx percy exec -- protractor conf.js
819
+
820
+ ${percyReviewSnapshotsStep}
821
+ `;
822
+ // Percy TestCafe instructions for JavaScript
823
+ export const nodejsTestcafeInstructions = `
824
+ ---STEP---
825
+ Install Percy dependencies
826
+ - Install Percy CLI and TestCafe SDK:
827
+ npm install --save-dev @percy/cli @percy/testcafe
828
+
829
+ ---STEP---
830
+ Update your TestCafe test script
831
+ ${PERCY_SNAPSHOT_INSTRUCTION}
832
+ ${nodejsTestcafeInstructionsSnapshot}
833
+
834
+ ---STEP---
835
+ Run Percy with your tests
836
+ - Use the following command:
837
+ npx percy exec -- testcafe chrome:headless tests
838
+
839
+ ${percyReviewSnapshotsStep}
840
+ `;
841
+ // Percy Gatsby instructions for JavaScript
842
+ export const nodejsGatsbyInstructions = `
843
+ ---STEP---
844
+ Install Percy dependencies
845
+ - Install Percy CLI and Gatsby plugin:
846
+ npm install --save @percy/cli gatsby-plugin-percy
847
+
848
+ ---STEP---
849
+ Update your Gatsby configuration
850
+ ${PERCY_SNAPSHOT_INSTRUCTION}
851
+ ${nodejsGatsbyInstructionsSnapshot}
852
+
853
+ ---STEP---
854
+ Run Percy with your Gatsby build
855
+ - Use the following command:
856
+ npx percy exec -- gatsby build
857
+
858
+ ${percyReviewSnapshotsStep}
859
+ `;
860
+ // Percy Storybook instructions for JavaScript
861
+ export const nodejsStorybookInstructions = `
862
+ ---STEP---
863
+ Install Percy dependencies
864
+ - Install Percy CLI and Storybook SDK:
865
+ npm install --save-dev @percy/cli @percy/storybook
866
+
867
+ ---STEP---
868
+ Update your Storybook stories
869
+ ${PERCY_SNAPSHOT_INSTRUCTION}
870
+ ${nodejsStorybookInstructionsSnapshot}
871
+
872
+ ---STEP---
873
+ Run Percy with your Storybook
874
+ - With a static Storybook build:
875
+ percy storybook ./storybook-build
876
+ - With a local or live Storybook URL:
877
+ percy storybook http://localhost:9009
878
+ percy storybook https://storybook.foobar.com
879
+ - Automatically run start-storybook:
880
+ percy storybook:start --port=9009 --static-dir=./public
881
+
882
+ - Example output:
883
+ [percy] Snapshot found: My snapshot
884
+ [percy] - url: [...]?id=component--my-story
885
+ [percy] Snapshot found: [Dark mode] My snapshot
886
+ [percy] - url: [...]?id=component--my-story&args=colorScheme:dark
887
+ [percy] Snapshot found: My snapshot with globals
888
+ [percy] - url: [...]?id=component--my-story&globals=textDirection:rtl
889
+ [percy] Snapshot found: Search snapshot
890
+ [percy] - url: [...]?id=component--my-story&search=foobar
891
+
892
+ ${percyReviewSnapshotsStep}
893
+ `;
894
+ export const pythonPlaywrightInstructions = `
895
+ ---STEP---
896
+ Create a Percy project
897
+ - Sign in to Percy and create a project of type "Web". Name the project and note the generated token.
898
+
899
+ ---STEP---
900
+ Set the project token as an environment variable
901
+ - On macOS/Linux:
902
+ export PERCY_TOKEN="<your token here>"
903
+ - On Windows PowerShell:
904
+ $env:PERCY_TOKEN="<your token here>"
905
+ - On Windows CMD:
906
+ set PERCY_TOKEN=<your token here>
907
+
908
+ ---STEP---
909
+ Install Percy dependencies
910
+ - Install Percy Playwright SDK:
911
+ pip install percy-playwright
912
+
913
+ ---STEP---
914
+ Update your Playwright Python test
915
+ ${PERCY_SNAPSHOT_INSTRUCTION}
916
+ ${pythonPlaywrightInstructionsSnapshot}
917
+
918
+ ---STEP---
919
+ Run Percy with your tests
920
+ - Use the following command:
921
+ npx percy exec -- python your_test_script.py
922
+
923
+ ${percyReviewSnapshotsStep}
924
+ `;
925
+ export const csharpPlaywrightInstructions = `
926
+ Install Percy dependencies
927
+ - Add the Percy Playwright NuGet package:
928
+ <PackageReference Include="PercyIO.Playwright" Version="1.0.0" />
929
+
930
+ ---STEP---
931
+ Update your Playwright .NET test
932
+ ${PERCY_SNAPSHOT_INSTRUCTION}
933
+ ${csharpPlaywrightInstructionsSnapshot}
934
+
935
+ ---STEP---
936
+ Run Percy with your tests
937
+ - Use the following command:
938
+ npx percy exec -- dotnet test
939
+
940
+ ${percyReviewSnapshotsStep}
941
+ `;