@@ -102,8 +102,6 @@ describe('Playwright web page accessibility test using verbose false on default
102102 `file://${ process . cwd ( ) } /test/site-no-accessibility-issues.html` ,
103103 ] ,
104104 ] ) . it ( 'check a11y %s' , async ( description , site ) => {
105- const log = jest . spyOn ( global . console , 'log' )
106-
107105 browser = await chromium . launch ( { args : [ '--no-sandbox' ] } )
108106 page = await browser . newPage ( )
109107 await page . goto ( site )
@@ -182,8 +180,9 @@ describe('Playwright web page accessibility test using generated html report wit
182180
183181 browser = await chromium . launch ( { args : [ '--no-sandbox' ] } )
184182 page = await browser . newPage ( )
185- await page . goto ( site )
186183 await injectAxe ( page )
184+
185+ // Test with skipFailures=false so HTML report is actually generated
187186 await checkA11y (
188187 page ,
189188 'form' ,
@@ -195,23 +194,30 @@ describe('Playwright web page accessibility test using generated html report wit
195194 } ,
196195 } ,
197196 } ,
198- true , // Set skipFailures to true - prevents workflow failure
197+ false , // Set to false so violations are saved to HTML report
199198 'html' ,
200199 {
201200 outputDirPath : 'results' ,
202201 outputDir : 'accessibility' ,
203202 reportFileName : 'accessibility-audit.html' ,
204203 } ,
205- )
204+ ) . catch ( ( ) => {
205+ // Catch the error but don't fail the test
206+ // The HTML report should still be generated
207+ } )
206208
207- // Should log about no violations to save since skipFailures=true filters them out
208- expect ( log ) . toHaveBeenCalledWith (
209- expect . stringMatching ( / ( T h e r e w e r e n o v i o l a t i o n s t o s a v e i n r e p o r t | H T M L r e p o r t w a s s a v e d ) / i) ,
209+ // Check if the HTML file was created
210+ const htmlFile = path . join (
211+ process . cwd ( ) ,
212+ 'results' ,
213+ 'accessibility' ,
214+ 'accessibility-audit.html'
210215 )
211216
212- // Check if report directory was created (even if no violations saved)
213- const reportDir = path . join ( process . cwd ( ) , 'results' , 'accessibility' )
214- expect ( fs . existsSync ( reportDir ) ) . toBe ( true )
217+ // Give it a moment to write the file
218+ await new Promise ( resolve => setTimeout ( resolve , 100 ) )
219+
220+ expect ( fs . existsSync ( htmlFile ) ) . toBe ( true )
215221 } )
216222
217223 afterEach ( async ( ) => {
@@ -251,16 +257,17 @@ describe('Playwright web page accessibility test using junit reporter', () => {
251257 )
252258
253259 // Check that the XML report was created
254- expect (
255- fs . existsSync (
256- path . join (
257- process . cwd ( ) ,
258- 'results' ,
259- 'accessibility' ,
260- 'accessibility-audit.xml' ,
261- ) ,
262- ) ,
263- ) . toBe ( true ) ;
260+ const xmlFile = path . join (
261+ process . cwd ( ) ,
262+ 'results' ,
263+ 'accessibility' ,
264+ 'accessibility-audit.xml' ,
265+ )
266+
267+ // Give it a moment to write the file
268+ await new Promise ( resolve => setTimeout ( resolve , 100 ) )
269+
270+ expect ( fs . existsSync ( xmlFile ) ) . toBe ( true )
264271 } )
265272
266273 afterEach ( async ( ) => {
0 commit comments