Conversation
|
Current unit coverage is 89.77272727272727% |
There was a problem hiding this comment.
Pull request overview
This PR adds a mutex-based serialization mechanism to the WCAG test runner to fix flaky test failures caused by concurrent axe accessibility checks. The implementation uses a promise chain to ensure that axe checks run sequentially rather than in parallel.
Changes:
- Introduced a global
axeLockpromise to serialize axe accessibility checks - Wrapped the
checkA11ycall in a promise chain to prevent concurrent execution - Added comments explaining the purpose of the serialization
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| axeLock = axeLock.then(async () => { | ||
| await checkA11y( | ||
| page, | ||
| { | ||
| exclude: [ | ||
| '#root .mapboxgl-canvas-container', | ||
| '.mapboxgl-marker', | ||
| '.mapboxgl-popup-close-button' | ||
| ], | ||
| }, | ||
| } | ||
| ); | ||
| { | ||
| axeOptions: { | ||
| runOnly, | ||
| rules: { | ||
| 'color-contrast': { enabled: context.name !== 'Loading' }, | ||
| }, | ||
| }, | ||
| detailedReport: true, | ||
| detailedReportOptions: { | ||
| html: true, | ||
| }, | ||
| } | ||
| ); | ||
| }); |
There was a problem hiding this comment.
The lock implementation doesn't properly handle errors. If checkA11y throws an error, it will break the promise chain and cause all subsequent tests to hang indefinitely waiting for a promise that will never resolve. The callback passed to then() should explicitly return the promise, and error handling should be added to prevent the lock from becoming permanently broken. Consider wrapping the checkA11y call in a try-finally block or using catch() to ensure the lock chain continues even when errors occur.
Adds a lock to WCAG test runner to try to fix it's flaky failures.