Skip to content

Commit

Permalink
Fix cypress support file
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh committed Jan 21, 2025
1 parent 818c024 commit 84c9a85
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ ci-acceptance-backend-start: ## Start backend acceptance server in headless mode

.PHONY: acceptance-test
acceptance-test: ## Start Cypress in interactive mode
pnpm --filter @plone/volto exec cypress open --config-file $(CURRENT_DIR)/cypress.config.js --config specPattern=$(CURRENT_DIR)'/cypress/tests/**/*.{js,jsx,ts,tsx}'
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'

.PHONY: ci-acceptance-test
ci-acceptance-test: ## Run cypress tests in headless mode for CI
Expand Down
11 changes: 10 additions & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ module.exports = defineConfig({
},
e2e: {
baseUrl: 'http://localhost:3000',
specPattern: 'cypress/tests/**/*.cy.{js,jsx,ts,tsx}',
specPattern: 'cypress/tests/*.cy.{js,jsx}',
supportFile: './cypress/support/e2e.js',
setupNodeEvents(on, config) {
on('task', {
table(message) {
console.table(message);
return null;
},
});
},
},
});
38 changes: 19 additions & 19 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import '@plone/volto/cypress/add-commands';

// Print cypress-axe violations to the terminal
function printAccessibilityViolations(violations) {
cy.task(
'table',
violations.map(({ id, impact, description, nodes }) => ({
impact,
description: `${description} (${id})`,
nodes: nodes.length,
})),
);
}
Cypress.Commands.add(
'checkAccessibility',
(subject, { skipFailures = false } = {}) => {
cy.checkA11y(subject, null, printAccessibilityViolations, skipFailures);
},
{
prevSubject: 'optional',
},
);
cy.task(
'table',
violations.map(({ id, impact, description, nodes }) => ({
impact,
description: `${description} (${id})`,
nodes: nodes.length,
})),
);
}

Cypress.Commands.add(
'checkAccessibility',
(subject, { skipFailures = false } = {}) => {
cy.checkA11y(subject, null, printAccessibilityViolations, skipFailures);
},
{
prevSubject: 'optional',
},
);
2 changes: 1 addition & 1 deletion cypress/tests/block.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ context('Block Acceptance Tests', () => {

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

cy.injectAxe();
cy.injectAxe({ axeCorePath: './node_modules/axe-core/axe.min.js' });
cy.checkAccessibility();
});
});

0 comments on commit 84c9a85

Please sign in to comment.