Skip to content

Commit

Permalink
added a11y test to test-runner
Browse files Browse the repository at this point in the history
  • Loading branch information
Gkrumbach07 committed Mar 1, 2023
1 parent e27234c commit 6d60ecf
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ Run the tests.
$ npm run test
```

Run storybook a11y tests and interaction tests.

```
$ npm run storybook
$ npm run test:storybook
```

For in-depth testing guidance review the [contribution guidelines](./CONTRIBUTING.md#Testing)

## Deploying the ODH Dashbard
Expand Down
28 changes: 28 additions & 0 deletions frontend/.storybook/test-runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { injectAxe, checkA11y, configureAxe } = require('axe-playwright');

const { getStoryContext } = require('@storybook/test-runner');
/*
* See https://storybook.js.org/docs/react/writing-tests/test-runner#test-hook-api-experimental
* to learn more about the test-runner hooks API.
*/
module.exports = {
async preRender(page) {
await injectAxe(page);
},
async postRender(page, context) {
// Get the entire context of a story, including parameters, args, argTypes, etc.
const storyContext = await getStoryContext(page, context);

// Apply story-level a11y rules
await configureAxe(page, {
rules: storyContext.parameters?.a11y?.config?.rules,
});

await checkA11y(page, storyContext.parameters?.a11y?.element ?? "#root", {
detailedReport: true,
detailedReportOptions: {
html: true,
},
});
},
};
27 changes: 27 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
"test:local": "jest --watchAll",
"test:type-check": "tsc --noEmit",
"test:storybook": "test-storybook --verbose",
"storybook": "start-storybook -p 6006 -s ./config",
"build-storybook": "build-storybook"
"storybook": "start-storybook -p 6006 -s ./config"
},
"dependencies": {
"@openshift/dynamic-plugin-sdk": "^1.0.0-alpha12",
Expand Down Expand Up @@ -94,6 +93,7 @@
"@types/showdown": "^1.9.3",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@typescript-eslint/parser": "^5.53.0",
"axe-playwright": "^1.2.3",
"babel-loader": "^8.3.0",
"copy-webpack-plugin": "^6.2.1",
"css-loader": "^5.2.7",
Expand Down

0 comments on commit 6d60ecf

Please sign in to comment.