-
Notifications
You must be signed in to change notification settings - Fork 1
/
axe-tests.runner.js
61 lines (55 loc) · 1.61 KB
/
axe-tests.runner.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import path from 'path'
import fs from 'fs'
import initStoryshots from '@storybook/addon-storyshots'
import { axeTest } from '@storybook/addon-storyshots-puppeteer'
import { logger } from '@storybook/node-logger'
const getStorybookUrl = () => {
if (process.env.USE_STATIC_STORYBOOK) {
const pathToStorybookStatic = path.join(__dirname, 'storybook-static')
if (!fs.existsSync(pathToStorybookStatic)) {
logger.error(
'You are running puppeteer tests without having the static build of storybook. Please run "npm run build-storybook" before running tests.'
)
return null
}
return `file://${pathToStorybookStatic}`
}
return 'http://localhost:6006'
}
const BROKEN_STORIES = [
'Compounds/Carousel',
'Compounds/HeroCard',
'Compounds/InteractiveTabs',
'Compounds/Sponsored Product Rate Table',
'Compounds/Sponsored product',
'Compounds/Testimonial Card',
'Elements/Accordion',
'Elements/Author',
'Elements/Breadcrumbs',
'Elements/Button Link',
'Elements/Button',
'Elements/Call Out',
'Elements/Card',
'Elements/Category',
'Elements/Drawer',
'Elements/Hero',
'Elements/HeroWithBackgroundImage',
'Elements/Link List',
'Elements/Pagination',
'Elements/Text Input',
'Global Styles/Typography',
'Layout/Arrangement',
'Layout/Flex Grid',
'Layout/Grid',
'Legacy Styles/Typography'
]
const storyKindRegex = new RegExp(`^(?!^(${BROKEN_STORIES.join('|')})$).*$`)
const storybookUrl = getStorybookUrl()
if (storybookUrl != null) {
initStoryshots({
suite: 'A11y checks',
storyKindRegex,
framework: 'react',
test: axeTest({ storybookUrl })
})
}