実現したいこと
以下のテストが通るようにしたいです。
const wrapper = shallow(<Counter />); // state: countを変更する処理 expect(wrapper.find("p").text()).toBe("100");
ソースコード
const Counter = () => { const [count, setCount] = React.useState(0); return <p>{count}</p> };
試したこと
wrapper.setState()を利用したのですがクラスコンポーネントではないので、
setState() can only be called on class components
というエラーが発生しました。
あなたの回答
tips
プレビュー