Not accessible
React told me off!
Why test code?
Reduce errors on complex interactive sites
React
Testing Library
Enforce user centric tests
<Button
label="Add a new fish"
onClick="this.showFishInput"
/>
<Input
aria-label="Fish name"
class="fishInput"
/>
fireEvent.showFishInput()
expect(<Input class="fishInput"/>) to render 🤯
<Button
label="Add a new fish"
onClick="this.showFishInput"
/>
<Input
aria-label="Fish name"
class="fishInput"
/>
userEvent.click(screen.getByText('Add a new fish'));
expect(
screen.getByRole('input', { name: 'Fish name' })
).toBeInTheDocument(); ❤️
What about React?
Improved docs,
development assistance, & bundling
<img src="fishyImage.png"/>
(image-alt):
Ensures <img> elements have alternate text
or a role of none or presentation
<button tabindex="2">
Add a new fish
</button>
(tabindex):
Ensures tabindex attribute values
are not greater than 0
Create React App
People can
ignore tests?!
Yes... but you can make it harder
Bake it in
TDD, prevent commits & stop deploys
React told me off
...but not all the time
Bots don't know UX
Good HTML & copy...
We need humans for that
Accessibility is a mindset,
not a standalone activity