Skip to content
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

docs: fix results-api.mdx getResults script #6021

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 22 additions & 23 deletions docs/accessibility/results-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@ The Cypress App [repository](https://github.com/cypress-io/cypress) uses the Res
```javascript title="scripts/verifyAccessibilityResults.js"
const { getAccessibilityResults } = require('@cypress/extract-cloud-results')

/**
* The list of rules that currently have 1+ elements that have been flagged with
* violations within the Cypress Accessibility report that need to be addressed.
*
* Once the violation is fixed in the Accessibility report,
* the fixed rule should be removed from this list.
*
* View the Accessibility report for the Cypress run in the Cloud
* for more details on how to address these failures.
*/
const rulesWithExistingViolations = [
'aria-required-children',
'empty-heading',
'aria-dialog-name',
'link-in-text-block',
'list',
]

getAccessibilityResults({
projectId: '...', // optional if set from env
recordKey: '...', // optional if set from env
Expand All @@ -60,11 +78,10 @@ getAccessibilityResults({
const { runNumber, accessibilityReportUrl, summary, rules } = results
const { total } = summary.violationCounts

console
.log(
`Received ${summary.isPartialReport ? 'partial' : ''} results for run #${runNumber}.`
)
.console.log(`See full report at ${accessibilityReportUrl}.`)
console.log(
`Received ${summary.isPartialReport ? 'partial' : ''} results for run #${runNumber}.`
)
console.log(`See full report at ${accessibilityReportUrl}.`)

// write your logic to conditionally fail based on the results
if (total === 0) {
Expand Down Expand Up @@ -101,24 +118,6 @@ getAccessibilityResults({
}

console.log('No new Accessibility violations detected!')

/**
* The list of rules that currently have 1+ elements that have been flagged with
* violations within the Cypress Accessibility report that need to be addressed.
*
* Once the violation is fixed in the Accessibility report,
* the fixed rule should be removed from this list.
*
* View the Accessibility report for the Cypress run in the Cloud
* for more details on how to address these failures.
*/
const rulesWithExistingViolations = [
'aria-required-children',
'empty-heading',
'aria-dialog-name',
'link-in-text-block',
'list',
]
})
```

Expand Down
9 changes: 4 additions & 5 deletions docs/ui-coverage/results-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ getUICoverageResults({
}).then((results) => {
const { runNumber, uiCoverageReportUrl, summary, views } = results

console
.log(
`Received ${summary.isPartialReport ? 'partial' : ''} results for run #${runNumber}.`
)
.console.log(`See full report at ${uiCoverageReportUrl}.`)
console.log(
`Received ${summary.isPartialReport ? 'partial' : ''} results for run #${runNumber}.`
)
console.log(`See full report at ${uiCoverageReportUrl}.`)

// verify project coverage
if (summary.coverage < 80) {
Expand Down