Skip to content

Commit

Permalink
Merge pull request #8 from IQSS/feature/storybook-setup
Browse files Browse the repository at this point in the history
3 - Storybook Setup
  • Loading branch information
kcondon committed Feb 28, 2023
2 parents 5e2619f + e8399a1 commit 0c6b1c1
Show file tree
Hide file tree
Showing 26 changed files with 28,376 additions and 14,703 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,25 @@ jobs:
build: npm run build
start: npm run start
wait-on: 'http://localhost:3000'
interaction-and-accessibility:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 19
cache: 'npm'

- name: Install Dependencies
run: npm install

- name: Build Storybook
run: npm run build-storybook --quiet

- name: Serve Storybook and run tests
run: |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
"npx http-server storybook-static --port 6006 --silent" \
"npx wait-on http://127.0.0.1:6006 --l && npx test-storybook --url http://127.0.0.1:6006"
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy-peer-deps=true
15 changes: 15 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/preset-create-react-app',
'storybook-react-i18next',
'@storybook/addon-a11y'
],
framework: '@storybook/react',
core: {
builder: '@storybook/builder-webpack5'
}
}
17 changes: 17 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import i18next from '../src/i18n'
import '../src/assets/styles/index.scss'

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/
}
},
i18next,
locale: 'en',
locales: {
en: 'English'
}
}
23 changes: 23 additions & 0 deletions .storybook/test-runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { injectAxe, checkA11y, configureAxe } = require('axe-playwright')

const { getStoryContext } = require('@storybook/test-runner')

module.exports = {
async preRender(page) {
await injectAxe(page)
},
async postRender(page, context) {
const storyContext = await getStoryContext(page, context)

await configureAxe(page, {
rules: storyContext.parameters?.a11y?.config?.rules
})

await checkA11y(page, '#root', {
detailedReport: true,
detailedReportOptions: {
html: true
}
})
}
}

0 comments on commit 0c6b1c1

Please sign in to comment.