Overview
Use the WebdriverIO API configuration to customize how Level CI runs
accessibility analysis in your WebdriverIO tests. You can configure
Level CI globally with levelSetup() or override settings
for individual tests with levelAnalyze().
API Methods
levelAnalyze
levelAnalyze(browser: Browser, config?: LaunchConfig): Promise<AnalysisResultData>
Runs a static accessibility analysis on the current page and generates a folder with analysis result data.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
browser
|
WebdriverIO.Browser
|
— | WebdriverIO Browser object to analyze |
config
|
LaunchConfig
|
{}
|
Optional configuration object |
Returns
Returns a Promise, which should resolve, otherwise return value will contain error object.
Usage
Important: Make sure to use levelAnalyze after your
tests have run successfully. If you add it to some kind of an
afterEach hook, add a condition to check the success
of test execution.
Otherwise, every rerun of a test, if you have retries, will produce a new report that is to be uploaded and processed, even when the test fails in the middle of execution.
levelSetup
levelSetup(config: LaunchConfig): void
Configure global settings for all Level CI analysis runs. Use this in your WebdriverIO support file or before tests for a clean setup.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
config
|
LaunchConfig
|
—
|
Global configuration object |
Returns
No return value (void). Configuration is stored globally and applied
to all subsequent levelAnalyze calls.
Note: Global configuration can be overridden per test. For this provide
config per levelAnalyze call. Arrays and objects are
merged with test-level config.
Usage
You can use levelSetup in your support file so all tests
use the same defaults.
Config
LaunchConfig
Configuration options
| Option | Type | Description |
|---|---|---|
switchOff
|
boolean
|
Disable rules check globally or per specific test. Default:
false. Environment variable:
LEVEL_CI_SWITCH_OFF. Example value: true.
|
reportPath
|
string
|
Folder path to store analysis artifacts. Default:
level-ci-reports. Environment variable:
LEVEL_CI_REPORT_PATH. Example value:
my-custom-report-path.
|
ignoreUrls
|
RegExp[]
|
Skip analysis for URLs matching these patterns. Example
value: [/home/, /settings\/privacy/, /articles\/*/].
|
customTags
|
string[]
|
Add custom tags for scan identification. Example values:
['alpha', 'beta', 'scenario-1'].
|
stableSelectorAttributes
|
string[]
|
Add to reliably identify elements with dynamic IDs. Example
values: ['data-testid'].
|
Custom tags
If you pass scenario-1 as a custom tag, you will see
it among the other tags for the newly found issues on the dashboard.
This way you can identify which issue appeared, while testing
scenario-1.
Stable selector attributes
Flaky issues often occur when elements have dynamic IDs. Level CI tracks elements across scans to monitor accessibility issues, but if an element’s id changes between scans, it treats it as a new element. This causes old issues to close and new issues to open for the same element.
Component-level screenshots (experimental)
To enable component-level screenshots for detected accessibility
issues, add the experimental.elementScreenshots option
to your levelAnalyze() configuration.
This setting is currently experimental. Enabling component-level screenshots may increase scan execution time because screenshots are captured during the accessibility analysis.
Examples
Use these examples to set a custom report path, add stable selector attributes, disable rule checks, add tags, and ignore specific URLs during analysis.