Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to config checkA11y for all tests #156

Open
kitsguru opened this issue Mar 27, 2023 · 1 comment
Open

how to config checkA11y for all tests #156

kitsguru opened this issue Mar 27, 2023 · 1 comment

Comments

@kitsguru
Copy link

kitsguru commented Mar 27, 2023

I have a series of specs for different sections and modules of my app. I would like to configure checkA11y in one location for all specs.

This works within each test

cy.checkA11y(null, {
    rules: {
		'color-contrast': { enabled: false },
		'frame-title': { enabled: false },
		},
});

I tried to set the configuration in support/index.js but I get an error

beforeEach(function () {
	// runs before each test in the block
	cy.visit('/')
	cy.injectAxe()
	cy.configureAxe({
		rules: {
			'color-contrast': { enabled: false },
			'frame-title': { enabled: false },
		},
	})
});

I am unsure where to set this up correctly.

@aamir-yaseen-baba
Copy link

aamir-yaseen-baba commented Apr 14, 2023

In the support, folder create a file e.g say axe-cofig.js and in that file create an object like this

export const defaultAxeConfiguration = {
    rules:[ {
       id: 'color-contrast', enabled: true,
    }],
    disableOtherRules: true,
};

and write your beforeEach like this
beforeEach(()=>{ cy.visit('/') cy.injectAxe() cy.configureAxe(defaultAxeConfiguration) })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants