Skip to content

Commit 99b95bb

Browse files
committed
adding in browser tests
1 parent 50275d0 commit 99b95bb

20 files changed

Lines changed: 214 additions & 2 deletions

.storybook/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default {
99
'@storybook/addon-a11y',
1010
'@chromatic-com/storybook',
1111
'@storybook/addon-docs',
12+
'@storybook/addon-vitest',
1213
],
1314

1415
docs: {
@@ -24,6 +25,12 @@ export default {
2425

2526
async viteFinal(config, { configType }) {
2627
config.base = process.env.BASE_PATH || config.base;
28+
if (process.env.STORYBOOK_CONFIG_DIR) {
29+
config.test = {
30+
...(config.test ?? {}),
31+
name: `storybook:${process.env.STORYBOOK_CONFIG_DIR}`,
32+
};
33+
}
2734

2835
// Skip type declaration generation for non-dist builds
2936
config.plugins = config.plugins.filter(

.storybook/preview.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,26 @@ export const preview = {
3535
],
3636
},
3737
},
38+
3839
actions: {},
40+
3941
controls: {
4042
matchers: {
4143
color: /(background|color)$/i,
4244
date: /Date$/,
4345
},
4446
},
47+
4548
docs: {
4649
theme: themeCFPB,
4750
},
51+
52+
a11y: {
53+
// 'todo' - show a11y violations in the test UI only
54+
// 'error' - fail CI on a11y violations
55+
// 'off' - skip a11y checks entirely
56+
test: 'todo',
57+
},
4858
},
4959

5060
tags: ['autodocs'],

.storybook/vitest.setup.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
2+
import { setProjectAnnotations } from '@storybook/react-vite';
3+
import * as projectAnnotations from './preview';
4+
5+
// This is an important step to apply the right configuration when testing your stories.
6+
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
7+
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
22.4 KB
Binary file not shown.
23.2 KB
Binary file not shown.
10.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)