「TestingLibraryElementError: Found multiple elements with the text」の解決方法【Vitest/React Testing Library】
- VitestでReactテスト中に複数のDOMがレンダリングされてエラーが発生
- beforeEachでrenderを実行しafterEachでcleanupを追加、またはグローバルにafterEachを設定
- テストごとにDOMをクリーンアップしないとエラーが発生するため、afterEachでcleanupを実行する
「TestingLibraryElementError: Found multiple elements with the text」の解決方法【Vitest/React Testing Library】 - Qiita


