Skip to content

Commit d13e527

Browse files
test: refactor cypress command to print a11y violations in the terminal
1 parent 3634761 commit d13e527

File tree

10 files changed

+27
-162
lines changed

10 files changed

+27
-162
lines changed

automation/run-e2e/support/commands.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,21 @@ const waitUntil = (subject, checkFunction, originalOptions = {}) => {
143143
};
144144

145145
Cypress.Commands.add("waitUntil", { prevSubject: "optional" }, waitUntil);
146+
147+
Cypress.Commands.add("terminalLog", violations => {
148+
cy.task(
149+
"log",
150+
`${violations.length} accessibility violation${violations.length === 1 ? "" : "s"} ${
151+
violations.length === 1 ? "was" : "were"
152+
} detected`
153+
);
154+
// pluck specific keys to keep the table readable
155+
const violationData = violations.map(({ id, impact, description, nodes }) => ({
156+
id,
157+
impact,
158+
description,
159+
nodes: nodes.length
160+
}));
161+
162+
cy.task("table", violationData);
163+
});

packages/pluggableWidgets/datagrid-date-filter-web/cypress/integration/DataGridDateFilter.spec.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
function terminalLog(violations) {
2-
cy.task(
3-
"log",
4-
`${violations.length} accessibility violation${violations.length === 1 ? "" : "s"} ${
5-
violations.length === 1 ? "was" : "were"
6-
} detected`
7-
);
8-
// pluck specific keys to keep the table readable
9-
const violationData = violations.map(({ id, impact, description, nodes }) => ({
10-
id,
11-
impact,
12-
description,
13-
nodes: nodes.length
14-
}));
15-
16-
cy.task("table", violationData);
17-
}
181
describe("datagrid-date-filter-web", () => {
192
const browserName = Cypress.browser.name;
203

@@ -98,7 +81,7 @@ describe("datagrid-date-filter-web", () => {
9881
values: ["wcag2a"]
9982
}
10083
},
101-
terminalLog
84+
cy.terminalLog
10285
);
10386
});
10487
});

packages/pluggableWidgets/datagrid-dropdown-filter-web/cypress/integration/DataGridDropDownFilter.spec.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
function terminalLog(violations) {
2-
cy.task(
3-
"log",
4-
`${violations.length} accessibility violation${violations.length === 1 ? "" : "s"} ${
5-
violations.length === 1 ? "was" : "were"
6-
} detected`
7-
);
8-
// pluck specific keys to keep the table readable
9-
const violationData = violations.map(({ id, impact, description, nodes }) => ({
10-
id,
11-
impact,
12-
description,
13-
nodes: nodes.length
14-
}));
15-
16-
cy.task("table", violationData);
17-
}
181
describe("datagrid-dropdown-filter-web", () => {
192
const browserName = Cypress.browser.name;
203

@@ -188,7 +171,7 @@ describe("datagrid-dropdown-filter-web", () => {
188171
values: ["wcag2a"]
189172
}
190173
},
191-
terminalLog
174+
cy.terminalLog
192175
);
193176
});
194177
});

packages/pluggableWidgets/datagrid-number-filter-web/cypress/integration/DataGridNumberFilter.spec.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
function terminalLog(violations) {
2-
cy.task(
3-
"log",
4-
`${violations.length} accessibility violation${violations.length === 1 ? "" : "s"} ${
5-
violations.length === 1 ? "was" : "were"
6-
} detected`
7-
);
8-
// pluck specific keys to keep the table readable
9-
const violationData = violations.map(({ id, impact, description, nodes }) => ({
10-
id,
11-
impact,
12-
description,
13-
nodes: nodes.length
14-
}));
15-
16-
cy.task("table", violationData);
17-
}
181
describe("datagrid-number-filter-web", () => {
192
const browserName = Cypress.browser.name;
203

@@ -78,7 +61,7 @@ describe("datagrid-number-filter-web", () => {
7861
values: ["wcag2a"]
7962
}
8063
},
81-
terminalLog
64+
cy.terminalLog
8265
);
8366
});
8467
});

packages/pluggableWidgets/datagrid-text-filter-web/cypress/integration/DataGridTextFilter.spec.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
function terminalLog(violations) {
2-
cy.task(
3-
"log",
4-
`${violations.length} accessibility violation${violations.length === 1 ? "" : "s"} ${
5-
violations.length === 1 ? "was" : "were"
6-
} detected`
7-
);
8-
// pluck specific keys to keep the table readable
9-
const violationData = violations.map(({ id, impact, description, nodes }) => ({
10-
id,
11-
impact,
12-
description,
13-
nodes: nodes.length
14-
}));
15-
16-
cy.task("table", violationData);
17-
}
181
describe("datagrid-text-filter-web", () => {
192
const browserName = Cypress.browser.name;
203

@@ -86,7 +69,7 @@ describe("datagrid-text-filter-web", () => {
8669
values: ["wcag2a"]
8770
}
8871
},
89-
terminalLog
72+
cy.terminalLog
9073
);
9174
});
9275
});

packages/pluggableWidgets/datagrid-web/cypress/integration/DataGrid.spec.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
function terminalLog(violations) {
2-
cy.task(
3-
"log",
4-
`${violations.length} accessibility violation${violations.length === 1 ? "" : "s"} ${
5-
violations.length === 1 ? "was" : "were"
6-
} detected`
7-
);
8-
// pluck specific keys to keep the table readable
9-
const violationData = violations.map(({ id, impact, description, nodes }) => ({
10-
id,
11-
impact,
12-
description,
13-
nodes: nodes.length
14-
}));
15-
16-
cy.task("table", violationData);
17-
}
181
describe("datagrid-web", () => {
192
const browserName = Cypress.browser.name;
203
const cleanMendixSession = () => {
@@ -165,7 +148,7 @@ describe("datagrid-web", () => {
165148
values: ["wcag2a"]
166149
}
167150
},
168-
terminalLog
151+
cy.terminalLog
169152
);
170153
});
171154
});

packages/pluggableWidgets/dropdown-sort-web/cypress/integration/DropDownSort.spec.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
function terminalLog(violations) {
2-
cy.task(
3-
"log",
4-
`${violations.length} accessibility violation${violations.length === 1 ? "" : "s"} ${
5-
violations.length === 1 ? "was" : "were"
6-
} detected`
7-
);
8-
// pluck specific keys to keep the table readable
9-
const violationData = violations.map(({ id, impact, description, nodes }) => ({
10-
id,
11-
impact,
12-
description,
13-
nodes: nodes.length
14-
}));
15-
16-
cy.task("table", violationData);
17-
}
181
describe("dropdown-sort-web", () => {
192
beforeEach(() => {
203
cy.visit("/");
@@ -62,7 +45,7 @@ describe("a11y testing:", () => {
6245
values: ["wcag2a"]
6346
}
6447
},
65-
terminalLog
48+
cy.terminalLog
6649
);
6750
});
6851
});

packages/pluggableWidgets/gallery-web/cypress/integration/Gallery.spec.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
function terminalLog(violations) {
2-
cy.task(
3-
"log",
4-
`${violations.length} accessibility violation${violations.length === 1 ? "" : "s"} ${
5-
violations.length === 1 ? "was" : "were"
6-
} detected`
7-
);
8-
// pluck specific keys to keep the table readable
9-
const violationData = violations.map(({ id, impact, description, nodes }) => ({
10-
id,
11-
impact,
12-
description,
13-
nodes: nodes.length
14-
}));
15-
16-
cy.task("table", violationData);
17-
}
181
describe("gallery-web", () => {
192
const browserName = Cypress.browser.name;
203

@@ -119,7 +102,7 @@ describe("gallery-web", () => {
119102
values: ["wcag2a"]
120103
}
121104
},
122-
terminalLog
105+
cy.terminalLog
123106
);
124107
});
125108
});

packages/pluggableWidgets/gallery-web/cypress/integration/GallerySelection.spec.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
function terminalLog(violations) {
2-
cy.task(
3-
"log",
4-
`${violations.length} accessibility violation${violations.length === 1 ? "" : "s"} ${
5-
violations.length === 1 ? "was" : "were"
6-
} detected`
7-
);
8-
// pluck specific keys to keep the table readable
9-
const violationData = violations.map(({ id, impact, description, nodes }) => ({
10-
id,
11-
impact,
12-
description,
13-
nodes: nodes.length
14-
}));
15-
16-
cy.task("table", violationData);
17-
}
181
describe("gallery-web", () => {
192
const browserName = Cypress.browser.name;
203

@@ -62,7 +45,7 @@ describe("gallery-web", () => {
6245
values: ["wcag2a"]
6346
}
6447
},
65-
terminalLog
48+
cy.terminalLog
6649
);
6750
});
6851
});

packages/pluggableWidgets/tree-node-web/cypress/integration/TreeNode.spec.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
function terminalLog(violations) {
2-
cy.task(
3-
"log",
4-
`${violations.length} accessibility violation${violations.length === 1 ? "" : "s"} ${
5-
violations.length === 1 ? "was" : "were"
6-
} detected`
7-
);
8-
// pluck specific keys to keep the table readable
9-
const violationData = violations.map(({ id, impact, description, nodes }) => ({
10-
id,
11-
impact,
12-
description,
13-
nodes: nodes.length
14-
}));
15-
16-
cy.task("table", violationData);
17-
}
181
describe("tree-node-web", () => {
192
const browserName = Cypress.browser.name;
203
const cleanMendixSession = () => {
@@ -91,7 +74,7 @@ describe("tree-node-web", () => {
9174
values: ["wcag2a"]
9275
}
9376
},
94-
terminalLog
77+
cy.terminalLog
9578
);
9679
});
9780
});

0 commit comments

Comments
 (0)