![](/img/trans.png)
[英]How can I write unit test for api call with token using React, Jest and React-testing-library?
[英]How to write Unit Test case for Switch Statement that returns Component in Jest with React Testing Library
當我編寫測試用例時,我能夠接觸到案例 0,但無法接觸到其他案例 1
const tabContent = (isCurrent) => { switch (isCurrent) { case 0: return <Component 1 />; case 1: return <Component 2 />; default: return null; } };
然后將 isCurrent 設置為 1 將 go 設置為第一種情況 tabContent(1) 任何其他值將 go 設置為默認值
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.