feat(sdk/testing): add toBeAccessible matcher for vitest assertions#4219
feat(sdk/testing): add toBeAccessible matcher for vitest assertions#4219Blackbaud-SteveBrush merged 17 commits intomainfrom
toBeAccessible matcher for vitest assertions#4219Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds Vitest integration and a custom accessibility matcher, relocates the a11y analyzer into a private testing library, introduces testing/build/config files for Vitest/Karma/ESLint/ng-packagr, updates exports and path aliases, and adds integration tests and type definitions. Changes
Sequence DiagramsequenceDiagram
participant Test as Test Suite
participant Matcher as toBeAccessible Matcher
participant Analyzer as SkyA11yAnalyzer
participant DOM as DOM/Element
Test->>Matcher: call toBeAccessible(element, config?)
Matcher->>Matcher: normalize & validate target
Matcher->>Analyzer: run(target, config)
Analyzer->>DOM: analyze via axe-core
Analyzer-->>Matcher: returns (success) or throws (violations)
alt No Violations
Matcher-->>Test: pass: true, message "No violations found"
else Violations Found
Matcher-->>Test: pass: false, message Error details
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit 4746ad7
☁️ Nx Cloud last updated this comment at |
toBeAccessible matcher for vitest assertionstoBeAccessible matcher for vitest assertions
There was a problem hiding this comment.
Pull request overview
This PR introduces Vitest support for SKY UX's accessibility testing capabilities by adding a toBeAccessible matcher for Vitest assertions, alongside a breaking change that moves internal types to a private secondary entry point.
Changes:
- Creates two new secondary entry points:
@skyux-sdk/testing/private(for internal implementation) and@skyux-sdk/testing/vitest/setup-matchers.js(for Vitest matcher registration) - Implements
toBeAccessiblecustom matcher for Vitest that leverages the existing axe-core accessibility analyzer - Refactors and improves test quality in the a11y analyzer by modernizing from callback-based patterns to async/await
- Fixes regex pattern bug in tag filtering (changed
best*tobestfor proper matching)
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.base.json | Adds TypeScript path mappings for the new private and vitest secondary entry points |
| libs/sdk/testing/vitest/vitest.config.ts | Configures Vitest integration tests to use jsdom environment and load the built matcher setup file |
| libs/sdk/testing/vitest/src/types/expectation-result.ts | Defines the return type interface for custom Vitest matchers |
| libs/sdk/testing/vitest/src/setup-matchers.integration.spec.ts | Integration tests verifying the matcher works correctly with accessible and inaccessible content |
| libs/sdk/testing/vitest/src/index.ts | Type declarations for the toBeAccessible matcher and module augmentation |
| libs/sdk/testing/vitest/src/a11y.matcher.ts | Implementation of the toBeAccessible matcher using SkyA11yAnalyzer |
| libs/sdk/testing/vitest/ng-package.json | Build configuration for the vitest secondary entry point |
| libs/sdk/testing/src/lib/matchers/matchers.ts | Updates import to use @skyux-sdk/testing/private for analyzer types |
| libs/sdk/testing/src/lib/matchers/matchers.spec.ts | Updates import to use @skyux-sdk/testing/private for analyzer config type |
| libs/sdk/testing/src/index.ts | Removes public exports of SkyA11yAnalyzer and SkyA11yAnalyzerConfig (breaking change) |
| libs/sdk/testing/project.json | Adds test-integration target for Vitest tests and testing-private:test dependency |
| libs/sdk/testing/private/tsconfig.spec.json | Test configuration for the private secondary entry point |
| libs/sdk/testing/private/src/index.ts | Exports SkyA11yAnalyzer and SkyA11yAnalyzerConfig from private entry point |
| libs/sdk/testing/private/src/a11y-analyzer.ts | Refactored analyzer with improved code formatting, regex fix, and @internal JSDoc |
| libs/sdk/testing/private/src/a11y-analyzer.spec.ts | Modernized tests using async/await instead of callbacks, added new test cases |
| libs/sdk/testing/private/src/a11y-analyzer-config.ts | Config interface with @internal JSDoc |
| libs/sdk/testing/private/project.json | Project configuration for the private secondary entry point |
| libs/sdk/testing/private/ng-package.json | Build configuration for the private secondary entry point |
| libs/sdk/testing/private/karma.conf.js | Karma test runner configuration |
| libs/sdk/testing/private/eslint.config.js | ESLint configuration |
| libs/sdk/testing/package.json | Adds vitest peer dependency (optional), exports configuration for setup-matchers subpath |
| libs/sdk/testing/README.md | Adds documentation for Vitest setup instructions |
There was a problem hiding this comment.
Actionable comments posted: 9
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@libs/sdk/testing/package.json`:
- Around line 18-23: Add a root export entry to the package's "exports" so
imports from "@skyux-sdk/testing" resolve; update the exports object to include
a "." key that points to the package's main bundles and types (e.g., point "."
-> "./fesm2022/skyux-sdk-testing.mjs" and types to
"./types/skyux-sdk-testing.d.ts" or the equivalent files used by this package)
so existing imports like "import { expect } from '@skyux-sdk/testing'" and
"import { SkyAppTestUtility } from '@skyux-sdk/testing'" continue to work;
ensure the new "." export mirrors the top-level entrypoints used by consumers
and coexists with the existing "./vitest/setup-matchers.js" subpath.
In `@libs/sdk/testing/private/karma.conf.js`:
- Around line 1-2: Remove the two header comment lines at the top of the Karma
configuration file (the lines starting with "// Karma configuration file..." and
"// https://karma-runner.github.io/...") to comply with the no-comments rule;
simply delete those comment lines so the file contains only executable
configuration code.
In `@libs/sdk/testing/private/src/a11y-analyzer-config.ts`:
- Around line 1-3: Remove the JSDoc comment block at the top of
a11y-analyzer-config.ts (the /** `@internal` */ block) so the file contains no
comments; simply delete those three comment lines and ensure no other comments
remain in the file to comply with the no-comments lint rule.
In `@libs/sdk/testing/private/src/a11y-analyzer.spec.ts`:
- Around line 129-134: The catch blocks in the tests call toMatch on the caught
error (err) which is typed as unknown; change the assertions to access the
Error.message property instead (e.g., expect((err as
Error).message).toMatch(...)) so the matcher receives a string and TypeScript is
satisfied; update each occurrence around SkyA11yAnalyzer.run in this file
(including the blocks at the shown diff and the other locations referencing
lines ~166-171 and ~219-221) to assert against err.message (or cast to Error)
and keep the existing regex checks.
In `@libs/sdk/testing/private/src/a11y-analyzer.ts`:
- Around line 87-89: Remove the newly added JSDoc block containing "@internal"
in libs/sdk/testing/private/src/a11y-analyzer.ts; delete the /** `@internal` */
comment so the file has no inline comments and rely on the package's private
entry point to indicate internal visibility instead.
In `@libs/sdk/testing/src/lib/matchers/matchers.spec.ts`:
- Around line 7-8: The inline eslint-disable comment on the import of
SkyA11yAnalyzerConfig in matchers.spec.ts should be removed and the
module-boundary policy updated to allow the private package instead; update your
`@nx/enforce-module-boundaries` configuration (or workspace/module boundary
settings) to permit the dependency on '@skyux-sdk/testing/private' for this
library (e.g., add it to allowedDependencies/allowedExternalDependencies or
adjust the relevant depConstraints for this package), then delete the "//
eslint-disable-next-line `@nx/enforce-module-boundaries`" line before the import
of SkyA11yAnalyzerConfig so the file contains a plain import without inline
comments.
In `@libs/sdk/testing/src/lib/matchers/matchers.ts`:
- Around line 2-6: Remove the inline eslint-disable comment on the import in
matchers.ts by updating the NX module-boundary rules: add
'@skyux-sdk/testing/private' to the allowedDependencies (or adjust the project's
module-boundary config) so the import of SkyA11yAnalyzer and
SkyA11yAnalyzerConfig no longer requires an inline disable; update the
workspace/project ESLint or nx.json moduleBoundary settings accordingly and then
delete the "// eslint-disable-next-line `@nx/enforce-module-boundaries`" line from
the import statement.
In `@libs/sdk/testing/vitest/src/a11y.matcher.ts`:
- Around line 1-5: Remove the inline eslint-disable comment before the import of
SkyA11yAnalyzer/SkyA11yAnalyzerConfig and instead handle this at config level:
either update ESLint config (overrides for this file pattern or a rule exception
for module-boundaries) to allow imports from '@skyux-sdk/testing/private' or
refactor exports so the public package can be used; locate the problematic
import statement referencing SkyA11yAnalyzer and SkyA11yAnalyzerConfig and
delete the inline suppression, then add the appropriate rule override in your
ESLint configuration (or adjust module boundaries) so the file no longer
requires an inline comment.
In `@libs/sdk/testing/vitest/src/index.ts`:
- Around line 1-18: Remove all inline comments and JSDoc from
libs/sdk/testing/vitest/src/index.ts: delete the eslint-disable line above the
SkyA11yAnalyzerConfig import and remove the JSDoc block above the
CustomMatchers.toBeAccessible signature, leaving only the TypeScript
declarations (interface CustomMatchers, toBeAccessible, and the declare module
'vitest' / Matchers extension). Move the removed documentation into the package
README or changelog and enforce the ESLint rule via a project-level override
(not inline) so no in-file disables remain.
toBeAccessible matcher for vitest assertionstoBeAccessible matcher for vitest assertions
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (2)
libs/sdk/testing/private/src/a11y-analyzer.spec.ts:134
- This assertion matches the thrown Error object against a regex. Since
SkyA11yAnalyzer.runrejects with an Error, it’s safer/clearer to match against(err as Error).message(as done elsewhere in this file) to avoid relying on object stringification.
libs/sdk/testing/private/src/a11y-analyzer.spec.ts:171 - This assertion matches the thrown Error object against a regex. Prefer matching against
(err as Error).messagefor consistency and to avoid depending on how the Error is stringified.
## [14.1.0](14.0.1...14.1.0) (2026-04-17) ### Features * **sdk/testing:** add `toBeAccessible` matcher for vitest assertions ([#4219](#4219)) ([56dedfe](56dedfe)) * **sdk/testing:** implement `ng add` schematic for `@skyux-sdk/testing` package ([#4376](#4376)) ([4db0f98](4db0f98)) ### Bug Fixes * **components/ag-grid:** header checkbox uses correct indeterminate styling when using native multiselect ([#4375](#4375)) ([04d11f7](04d11f7)) * **components/lists:** use correct padding on active toolbar filter button ([#4373](#4373)) ([07974aa](07974aa))
AB#3703606
Summary by CodeRabbit
New Features
Documentation
Refactor
Tests