File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -3,9 +3,11 @@ import {render} from '@testing-library/react'
33import { axe } from 'jest-axe'
44
55function InaccessibleForm ( ) {
6+ // Form inputs must have an accessible name
7+ // Ref: 4.1.1 of W3C HTML Accessibility API Mappings 1.0
68 return (
79 < form >
8- < input placeholder = "email " />
10+ < input id = "username " />
911 </ form >
1012 )
1113}
@@ -21,13 +23,11 @@ function AccessibleForm() {
2123
2224test ( 'inaccessible forms fail axe' , async ( ) => {
2325 const { container} = render ( < InaccessibleForm /> )
24- try {
25- expect ( await axe ( container ) ) . toHaveNoViolations ( )
26- } catch ( error ) {
27- // NOTE: I can't think of a situation where you'd want to test that some HTML
28- // actually _does_ have accessibility issues... This is only here for
29- // demonstration purposes.
30- }
26+ const axeResult = await axe ( container )
27+ expect ( ( ) => expect ( axeResult ) . toHaveNoViolations ( ) ) . toThrow ( )
28+ // NOTE: I can't think of a situation where you'd want to test that some HTML
29+ // actually _does_ have accessibility issues... This is only here for
30+ // demonstration purposes.
3131} )
3232
3333test ( 'accessible forms pass axe' , async ( ) => {
You can’t perform that action at this time.
0 commit comments