From 047c7eb0bac6cd5324defd207d1109f08bd7f668 Mon Sep 17 00:00:00 2001 From: Matyas Forian-Szabo Date: Mon, 5 Jan 2026 22:34:03 +0100 Subject: [PATCH] refactor: better logging for cypress test errors --- regression-test/cypress/e2e/spec.cy.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/regression-test/cypress/e2e/spec.cy.ts b/regression-test/cypress/e2e/spec.cy.ts index a88fea9612..b063b86529 100644 --- a/regression-test/cypress/e2e/spec.cy.ts +++ b/regression-test/cypress/e2e/spec.cy.ts @@ -41,25 +41,28 @@ afterEach(() => { }) }) -// log fn taken from https://www.npmjs.com/package/cypress-axe function terminalLog(violations: Result[]) { cy.task( 'log', `${violations.length} accessibility violation${ violations.length === 1 ? '' : 's' - } ${violations.length === 1 ? 'was' : 'were'} detected` + } ${violations.length === 1 ? 'was' : 'were'} detected.` ) - // pluck specific keys to keep the table readable - const violationData = violations.map( - ({ id, impact, description, nodes }) => ({ + + violations.map(({ id, impact, description, nodes }) => { + cy.task('table', { id, impact, description, - nodes: nodes.length + summary: nodes[0].failureSummary }) - ) - - cy.task('table', violationData) + const ret: any = {} + cy.task('log', 'This error happens in the following elements:') + nodes.forEach((item, index) => { + ret[`${item.target.join(',')}`] = { html: item.html } + }) + cy.task('table', ret) + }) } const axeOptions: { runOnly: RunOnly } = {