File tree 3 files changed +22
-4
lines changed
3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ - [ fix] Add handling for known axe-core conflicts [ #103 ] ( https://github.com/chanzuckerberg/axe-storybook-testing/pull/103 )
6
+
5
7
## 8.2.1 (2024-10-21)
6
8
7
9
- [ fix] Simplify the promise queue implementation [ #102 ] ( https://github.com/chanzuckerberg/axe-storybook-testing/pull/102 )
Original file line number Diff line number Diff line change @@ -59,6 +59,10 @@ export function analyze(
59
59
} ) ;
60
60
}
61
61
62
+ /**
63
+ * (In Browser Context)
64
+ *
65
+ */
62
66
function runAxe ( {
63
67
config,
64
68
context,
@@ -83,6 +87,7 @@ function runAxe({
83
87
window . axe . configure ( config ) ;
84
88
}
85
89
90
+ // API: https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#api-name-axerun
86
91
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
87
92
// @ts -ignore This function executes in a browser context.
88
93
return window . axe . run ( context || document , options ) ;
@@ -106,6 +111,8 @@ export function getRunOptions(
106
111
}
107
112
108
113
/**
114
+ * (In Browser Context)
115
+ *
109
116
* Add a promise queue so we can ensure only one promise runs at a time.
110
117
*
111
118
* Used to prevent concurrent runs of `axe.run`, which breaks (see https://github.com/dequelabs/axe-core/issues/1041).
Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ async function fetchStoriesFromWindow(): Promise<StorybookStory[]> {
116
116
117
117
/**
118
118
* Abuse Storybook's internal APIs to render a story without requiring a page reload (which would
119
- * be slow).
119
+ * be slow). Also set up globals for any values needed for the running tests.
120
120
*
121
121
* Doing so is brittle, and updates to Storybook could break this. The trade off is that we don't
122
122
* have to figure out how to process stories with Webpack - Storybook handles that for us.
@@ -134,10 +134,19 @@ function emitSetCurrentStory(id: string) {
134
134
) ;
135
135
}
136
136
137
- return new Promise ( ( resolve ) => {
138
- // @ts -expect-error Access the protected "channel", so we can send stuff through it.
139
- const channel = storybookPreview . channel ;
137
+ // @ts -expect-error Access the protected "channel", so we can send stuff through it.
138
+ const channel = storybookPreview . channel ;
140
139
140
+ // update global to disable known addons containing `axe-core`
141
+ channel . emit ( 'updateGlobals' , {
142
+ globals : {
143
+ a11y : {
144
+ manual : true ,
145
+ } ,
146
+ } ,
147
+ } ) ;
148
+
149
+ return new Promise ( ( resolve ) => {
141
150
channel . emit ( 'setCurrentStory' , {
142
151
storyId : id ,
143
152
viewMode : 'story' ,
You can’t perform that action at this time.
0 commit comments