| name | evinced-web-sdk |
| description | Use when adding accessibility scanning to existing Playwright checks via --evinced flag, when instrumenting browser tests for WCAG compliance, or when integrating Evinced SDK with Playwright scripts. |
Evinced Web SDK for Playwright
Instrument existing Playwright checks with Evinced accessibility scanning via the --evinced CLI flag.
Critical Setup Order
MUST set credentials BEFORE creating EvincedSDK instances:
const { EvincedSDK, setCredentials, setUploadToPlatformConfig } = require('@evinced/js-playwright-sdk');
const useEvinced = process.argv.includes('--evinced');
const uploadToPlatform = process.argv.includes('--upload=TRUE');
await setCredentials({
serviceId: process.env.EVINCED_SERVICE_ID,
secret: process.env.EVINCED_API_KEY,
});
setUploadToPlatformConfig({
enableUploadToPlatform: uploadToPlatform,
});
const page = await context.newPage();
const evincedService = new EvincedSDK(page);
Wrong order = authentication failures. Credentials MUST be set globally first.
Integration Pattern
Add --evinced and --upload=TRUE flag support to any existing Playwright script:
const useEvinced = process.argv.includes('--evinced');
const uploadToPlatform = process.argv.includes('--upload=TRUE');
if (useEvinced) {
const { setCredentials, setUploadToPlatformConfig } = require('@evinced/js-playwright-sdk');
await setCredentials({
serviceId: process.env.EVINCED_SERVICE_ID,
secret: process.env.EVINCED_API_KEY,
});
setUploadToPlatformConfig({ enableUploadToPlatform: uploadToPlatform });
}
let evincedService = null;
if (useEvinced) {
const { EvincedSDK } = require('@evinced/js-playwright-sdk');
evincedService = new EvincedSDK(page);
evincedService.testRunInfo.addLabel({ testName: 'My-Test-Name' });
await evincedService.evStart({
enableScreenshots: true,
});
}
if (evincedService) {
const issues = await evincedService.evStop();
await evincedService.evSaveFile(issues, 'html', 'results/accessibility/report.html');
console.log(`[EVINCED] Found ${issues.length} accessibility issues`);
}
Continuous vs Single-Page Scanning
| Pattern | Use When |
|---|
evStart() / evStop() | Test navigates, clicks, opens modals — captures DOM mutations |
evAnalyze() | Single snapshot of current page state |
Prefer continuous scanning (evStart/evStop) for integration tests. It catches issues that appear during interactions.
Triggering DOM Mutations
Evinced continuous mode captures accessibility issues as DOM changes. Interact with the page to expose hidden states:
await page.click('[data-at="nearby-stores-button"]');
await page.waitForTimeout(500);
await page.click('[data-at="close-modal-button"]');
await page.click('[data-at="add-to-cart-button"]');
await page.waitForTimeout(500);
await page.click('[data-at="product-details-accordion"]');
Report Output
await evincedService.evSaveFile(issues, 'html', 'report.html');
await evincedService.evSaveFile(issues, 'json', 'report.json');
await evincedService.evSaveFile(issues, 'sarif', 'report.sarif');
Output to results/accessibility/{script-name}/ following project conventions.
Environment Variables
export EVINCED_SERVICE_ID=<your-service-id>
export EVINCED_API_KEY=<your-api-key>
Platform upload is controlled via CLI flag --upload=TRUE, not environment variables.
Package Installation
npm install @evinced/js-playwright-sdk
Requires Playwright 1.25+.
Common Mistakes
| Mistake | Fix |
|---|
| Create EvincedSDK before setCredentials | Always call setCredentials() FIRST, before any SDK instantiation |
| evStop without evStart | Must call evStart() before evStop() |
| Forget to interact with page | DOM mutations trigger issue detection — click modals, forms, dropdowns |
| Missing screenshots in report | Add enableScreenshots: true to evStart() or evAnalyze() options |
| Accidentally uploading to platform | Default is NO upload. Use --upload=TRUE only when you want to upload |
Quick Reference
const useEvinced = process.argv.includes('--evinced');
const uploadToPlatform = process.argv.includes('--upload=TRUE');
const { EvincedSDK, setCredentials, setUploadToPlatformConfig } = require('@evinced/js-playwright-sdk');
await setCredentials({ serviceId: '...', secret: '...' });
setUploadToPlatformConfig({ enableUploadToPlatform: uploadToPlatform });
const evincedService = new EvincedSDK(page);
evincedService.testRunInfo.addLabel({ testName: 'PDP-Test' });
evincedService.testRunInfo.customLabel({ environment: 'QA', browser: 'chromium' });
await evincedService.evStart({ enableScreenshots: true });
const issues = await evincedService.evStop();
const issues = await evincedService.evAnalyze({ enableScreenshots: true });
await evincedService.evSaveFile(issues, 'html', 'path/report.html');