Skip to content

Commit

Permalink
docs: fix results-api.mdx getResults script
Browse files Browse the repository at this point in the history
  • Loading branch information
jsberlanga committed Nov 29, 2024
1 parent 80dd7cb commit 0dca969
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
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

0 comments on commit 0dca969

Please sign in to comment.