Slide 62
Slide 62 text
特定の要素があるか?or 消えているか?
testing-library とjestを使う
// 要素があるか?
// → 要素を findBy や getBy で取得する(⾒つからないとErrorになるので)
const addButton = await screen.findByRole('button', { name: '追加' });
// 要素が消えているか?
// → 要素を queryByで取得し、null であることを確かめる
const addButton = screen.queryByRole('button', { name: '追加' });
expect(addButton).toBeNull();