-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Cypress Rules documentation #6215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 22 commits
a45d9e6
b487069
e6e44af
4ca2f08
b46c8fe
b44267c
95c8f83
cd38608
f7c62a4
3076894
72618dc
14cb12c
5adad81
0d33a0c
adede79
c8d6bd7
6fd74b7
00dd572
ae485fc
b09ae57
05e7cbc
2fe3013
993b19e
3b0dba2
c0cf9bb
087bc82
e47a6e7
a5000ae
a09a9c3
3378f2b
55bbf33
d6c96d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,91 @@ | ||||||
--- | ||||||
title: 'Cypress Rules | Cypress Accessibility Documentation' | ||||||
description: 'Review the main areas to pay attention to when first reviewing an accessibility report for a Cypress run.' | ||||||
sidebar_position: 70 | ||||||
sidebar_label: Cypress rules | ||||||
sidebar_custom_props: { 'new_label': true } | ||||||
--- | ||||||
|
||||||
<ProductHeading product="accessibility" /> | ||||||
|
||||||
# Cypress rules | ||||||
|
||||||
In addition to running the default ruleset of the Axe-Core® library, Cypress develops custom rules that take advantage of the addition layer of information available in a test automation context. These rules are identified by a "Cypress Rule" badge, to distinguish them from the main Axe-Core® rule set. | ||||||
marktnoonan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
In addition to running the default ruleset of the Axe-Core® library, Cypress develops custom rules that take advantage of the addition layer of information available in a test automation context. These rules are identified by a "Cypress Rule" badge, to distinguish them from the main Axe-Core® rule set. | |
In addition to running the default ruleset of the Axe-Core® library, Cypress offers custom rules that take advantage of the additional layer of information available in the test automation context. These rules are identified by a "Cypress Rule" badge, to distinguish them from the main Axe-Core® rule set. |
marktnoonan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
marktnoonan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
marktnoonan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
marktnoonan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ Fetching Accessibility results for a run supports fetching results for the follo | |
- [GitLab](/app/continuous-integration/gitlab-ci) | ||
- [Jenkins](/app/continuous-integration/overview#Jenkins) | ||
- [AWS CodeBuild](/app/continuous-integration/aws-codebuild) | ||
- Drone | ||
|
||
Please reach out to Cypress Support to request support for a different provider. | ||
|
||
|
@@ -59,6 +60,25 @@ If you check this in as a dependency, your installation will fail when we update | |
|
||
Write a script using the `getAccessibilityResults` utility to retrieve the results and perform one or more assertions to verify if the changes are acceptable. This script will be executed in CI. | ||
|
||
#### Basic example | ||
|
||
This snippet uses the `getAccessibilityResults()` helper to log out the results. It assumes your Project ID and Record Key variable are set. The following should work in any of the supported CI Providers out of the box: | ||
|
||
```javascript title="scripts/verifyAccessibilityResults.js" | ||
// Assuming these environment variables are set: | ||
// CYPRESS_PROJECT_ID=your-id | ||
// CYPRESS_RECORD_KEY=your-record-key | ||
|
||
const { getAccessibilityResults } = require('@cypress/extract-cloud-results') | ||
|
||
getAccessibilityResults().then((results) => { | ||
// use `console.dir` instead of `console.log` because the data is nested | ||
console.dir(results, { depth: Infinity }) | ||
}) | ||
``` | ||
|
||
#### How to assert that only known rules are failing in the run | ||
|
||
The Cypress App [repository](https://github.com/cypress-io/cypress) uses the Results API to ensure no new violations have been introduced. You can reference [this script](https://github.com/cypress-io/cypress/blob/develop/scripts/verify-accessibility-results.js) as a real example. | ||
|
||
```javascript title="scripts/verifyAccessibilityResults.js" | ||
|
@@ -133,7 +153,23 @@ getAccessibilityResults({ | |
}) | ||
``` | ||
|
||
#### `getAccessibilityResults` Arguments | ||
#### How to use a previous run as a baseline | ||
|
||
```javascript title="scripts/verifyAccessibilityResults.js" | ||
|
||
// Assuming these environment variables are set: | ||
// CYPRESS_PROJECT_ID=your-id | ||
// CYPRESS_RECORD_KEY=your-record-key | ||
|
||
const { getAccessibilityResults } = require('@cypress/extract-cloud-results') | ||
|
||
getAccessibilityResults().then((results) => { | ||
// use `console.dir` instead of `console.log` | ||
// to ensure nested data prints out correctly | ||
console.dir(results, { depth: Infinity }) | ||
}) | ||
``` | ||
|
||
### `getAccessibilityResults` Arguments | ||
|
||
`getAccessibilityResults` uses the following attributes to identify the Cypress run and return the Accessibility results: | ||
|
||
|
@@ -444,5 +480,33 @@ phases: | |
+ - CYPRESS_INTERNAL_ENV=staging CYPRESS_PROJECT_ID=[slug] CYPRESS_RECORD_KEY=[KEY] node ./scripts/verifyAccessibilityResults.js | ||
``` | ||
|
||
</TabItem> | ||
|
||
<TabItem value="Drone" > | ||
```diff title=".drone.yaml" | ||
kind: pipeline | ||
name: default | ||
|
||
environment: | ||
CYPRESS_PROJECT_ID: example_project_slug | ||
CYPRESS_RECORD_KEY: | ||
from_secret: example_record_key_secret | ||
|
||
steps: | ||
|
||
- name: test | ||
image: node:latest | ||
commands: | ||
- npm install | ||
- npx cypress run --record | ||
|
||
* - name: validate | ||
* image: node:latest | ||
* commands: | ||
* - npm install --force https://cdn.cypress.io/extract-cloud-results/v1/extract-cloud-results.tgz | ||
* - node ./scripts/verifyAccessibilityResults.js | ||
|
||
``` | ||
</TabItem> | ||
</Tabs> | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marktnoonan Did you mean to put the new rules in the changelog?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding now, ty!