MockAxeBuilder
Playwright\Accessibility\Testing\MockAxeBuilder
Mock AxeBuilder for testing without a real browser.
This allows you to simulate accessibility test results in your unit tests
without needing to run Playwright or have axe-core available.
Methods
create()
selfCreate a new mock builder.
function create(): self
withViolation()
selfAdd a violation to the mock results.
function withViolation( RuleId|string $ruleId, ImpactLevel|string $impact = 'serious', array $selectors = [], ?string $help = null, ): self
withPass()
selfAdd a passing rule to the mock results.
function withPass(string $ruleId): self
withIncomplete()
selfAdd an incomplete rule to the mock results.
function withIncomplete(string $ruleId): self
withInapplicable()
selfAdd an inapplicable rule to the mock results.
function withInapplicable(string $ruleId): self
withNoViolations()
selfSimulate an accessible page with no violations.
function withNoViolations(): self
within()
selfFluent API compatibility: within() (no-op in mock).
function within(string $selector): self
exclude()
selfFluent API compatibility: exclude() (no-op in mock).
function exclude(string $selector): self
withTags()
selfFluent API compatibility: withTags() (no-op in mock).
function withTags(array $tags): self
withoutRules()
selfFluent API compatibility: withoutRules() (filters out violations in mock).
function withoutRules(array $rules): self
analyze()
AxeResultsGenerate the mock AxeResults.
function analyze(): AxeResults