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

feat: accessibility tests #194

Merged
merged 7 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
},

addons: [
'@storybook/addon-a11y',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
Expand All @@ -32,12 +33,12 @@ module.exports = {

framework: {
name: '@storybook/react-webpack5',
options: {}
options: {},
},

staticDirs: ['../static', '../public'],

docs: {
autodocs: true
}
autodocs: true,
},
};
2 changes: 1 addition & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ export const parameters = {
mswInitialize();

// Provide the MSW addon decorator globally
export const decorators = [mswDecorator];
export const decorators = [mswDecorator];
14 changes: 14 additions & 0 deletions .storybook/test-runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { injectAxe, checkA11y } = require('axe-playwright');
module.exports = {
preRender: async (page) => {
// before the story has been rendered inject AXE
await injectAxe(page);
},
postRender: async (page) => {
// after the story has been rendered rn AXE checksonly on root not the whole page
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// after the story has been rendered rn AXE checksonly on root not the whole page
// after the story has been rendered, run AXE checks only on root, not the whole page

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

await checkA11y(page, '#storybook-root', {
detailedReport: true,
detailedReportOptions: { html: true },
});
},
};
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
target: ${DOCKER_TARGET:-development}
ports:
- '3000:3000'
- '6006:6006' # Storybook
- '6006:6006' # Storybook
volumes:
- .:/app/
- /app/node_modules # Exclude node_modules
- /app/node_modules # Exclude node_modules
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"lint": "yarn eslint \"src/**/*.{ts,tsx}\" && yarn prettier ./src -c",
"lint-fix": "yarn eslint \"src/**/*.{ts,tsx}\" --fix && yarn prettier ./src -w",
"test": "jest",
"test-storybook": "test-storybook",
"build": "rollup -c --bundleConfigAsCjs",
"docker:dev": "cross-env DOCKER_TARGET=development docker compose up",
"docker:prod": "cross-env DOCKER_TARGET=production docker compose up",
Expand Down Expand Up @@ -71,6 +72,7 @@
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.0",
"@storybook/addon-a11y": "^7.3.1",
"@storybook/addon-actions": "^7.3.1",
"@storybook/addon-essentials": "^7.3.1",
"@storybook/addon-interactions": "^7.3.1",
Expand All @@ -79,6 +81,7 @@
"@storybook/preset-scss": "^1.0.3",
"@storybook/react": "^7.3.1",
"@storybook/react-webpack5": "^7.3.1",
"@storybook/test-runner": "^0.16.0",
"@storybook/testing-library": "^0.2.0",
"@testing-library/jest-dom": "^6.1.6",
"@testing-library/react": "^14.1.0",
Expand All @@ -91,6 +94,7 @@
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"axe-playwright": "^1.1.11",
"babel-loader": "^9.1.3",
"classnames": "^2.3.1",
"cross-env": "^7.0.3",
Expand Down
Loading
Loading