Skip to content

Commit 5475731

Browse files
committed
refactor: better logging for cypress test errors
1 parent ff38916 commit 5475731

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

regression-test/cypress/e2e/spec.cy.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,28 @@ afterEach(() => {
4141
})
4242
})
4343

44-
// log fn taken from https://www.npmjs.com/package/cypress-axe
4544
function terminalLog(violations: Result[]) {
4645
cy.task(
4746
'log',
4847
`${violations.length} accessibility violation${
4948
violations.length === 1 ? '' : 's'
50-
} ${violations.length === 1 ? 'was' : 'were'} detected`
49+
} ${violations.length === 1 ? 'was' : 'were'} detected.`
5150
)
52-
// pluck specific keys to keep the table readable
53-
const violationData = violations.map(
54-
({ id, impact, description, nodes }) => ({
51+
52+
violations.map(({ id, impact, description, nodes }) => {
53+
cy.task('table', {
5554
id,
5655
impact,
5756
description,
58-
nodes: nodes.length
57+
summary: nodes[0].failureSummary
5958
})
60-
)
61-
62-
cy.task('table', violationData)
59+
const ret: any = {}
60+
cy.task('log', 'This error happens in the following elements:')
61+
nodes.forEach((item, index) => {
62+
ret[`${item.target.join(',')}`] = { html: item.html }
63+
})
64+
cy.task('table', ret)
65+
})
6366
}
6467

6568
const axeOptions: { runOnly: RunOnly } = {

0 commit comments

Comments
 (0)