Skip to content

Commit 84c9a85

Browse files
committed
Fix cypress support file
1 parent 818c024 commit 84c9a85

File tree

4 files changed

+31
-22
lines changed

4 files changed

+31
-22
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ ci-acceptance-backend-start: ## Start backend acceptance server in headless mode
133133

134134
.PHONY: acceptance-test
135135
acceptance-test: ## Start Cypress in interactive mode
136-
pnpm --filter @plone/volto exec cypress open --config-file $(CURRENT_DIR)/cypress.config.js --config specPattern=$(CURRENT_DIR)'/cypress/tests/**/*.{js,jsx,ts,tsx}'
136+
pnpm --filter @plone/volto exec cypress open --config-file $(CURRENT_DIR)/cypress.config.js --config specPattern=$(CURRENT_DIR)'/cypress/tests/**/*.{js,jsx,ts,tsx}',supportFile=$(CURRENT_DIR)'/cypress/support/e2e.js'
137137

138138
.PHONY: ci-acceptance-test
139139
ci-acceptance-test: ## Run cypress tests in headless mode for CI

cypress.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ module.exports = defineConfig({
88
},
99
e2e: {
1010
baseUrl: 'http://localhost:3000',
11-
specPattern: 'cypress/tests/**/*.cy.{js,jsx,ts,tsx}',
11+
specPattern: 'cypress/tests/*.cy.{js,jsx}',
12+
supportFile: './cypress/support/e2e.js',
13+
setupNodeEvents(on, config) {
14+
on('task', {
15+
table(message) {
16+
console.table(message);
17+
return null;
18+
},
19+
});
20+
},
1221
},
1322
});

cypress/support/commands.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import '@plone/volto/cypress/add-commands';
22

33
// Print cypress-axe violations to the terminal
44
function printAccessibilityViolations(violations) {
5-
cy.task(
6-
'table',
7-
violations.map(({ id, impact, description, nodes }) => ({
8-
impact,
9-
description: `${description} (${id})`,
10-
nodes: nodes.length,
11-
})),
12-
);
13-
}
14-
15-
Cypress.Commands.add(
16-
'checkAccessibility',
17-
(subject, { skipFailures = false } = {}) => {
18-
cy.checkA11y(subject, null, printAccessibilityViolations, skipFailures);
19-
},
20-
{
21-
prevSubject: 'optional',
22-
},
23-
);
5+
cy.task(
6+
'table',
7+
violations.map(({ id, impact, description, nodes }) => ({
8+
impact,
9+
description: `${description} (${id})`,
10+
nodes: nodes.length,
11+
})),
12+
);
13+
}
14+
15+
Cypress.Commands.add(
16+
'checkAccessibility',
17+
(subject, { skipFailures = false } = {}) => {
18+
cy.checkA11y(subject, null, printAccessibilityViolations, skipFailures);
19+
},
20+
{
21+
prevSubject: 'optional',
22+
},
23+
);

cypress/tests/block.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ context('Block Acceptance Tests', () => {
105105

106106
cy.get('.teaser-item-title').should('be.visible').contains('My Page');
107107

108-
cy.injectAxe();
108+
cy.injectAxe({ axeCorePath: './node_modules/axe-core/axe.min.js' });
109109
cy.checkAccessibility();
110110
});
111111
});

0 commit comments

Comments
 (0)