Skip to main content

Cypress API

API Methods

cy.levelAnalyze

cy.levelAnalyze(config?: AnalyzeConfig): Chainable<AnalysisResult>

Runs a static accessibility analysis on the current page and generates a folder with analysis result data. By default, asserts that the number of violations is equal to zero.

Properties

Property Type Default Description
config AnalyzeConfig {} Optional configuration object

Returns

Returns a Cypress Chainable that resolves to the analysis result. Use .then() to access violations and reports when strict: false.

Usage

Important: Make sure to use cy.levelAnalyze() after your tests have run successfully. If you add it to 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: AnalyzeConfig): void

Configure global settings for all Level CI analysis runs. Use this in your Cypress support file for a clean setup.

Properties

Property Type Default Description
config AnalyzeConfig Global configuration object

Returns

No return value (void). Configuration is stored globally and applied to all subsequent cy.levelAnalyze calls.

Note: Global configuration can be overridden per test. For this provide config per cy.levelAnalyze call. Arrays and objects are merged with test-level config.

Config

AnalyzeConfig

Component-level screenshots (experimental)

To enable component-level screenshots for detected accessibility issues, add the experimental.elementScreenshots option to your cy.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

Examples

Use these examples to set a custom report path, disable rule checks, ignore specific URLs during analysis, add tags, and add stable selector attributes.

Powered by Zendesk