簡體   English   中英

如何對本機應用程序進行單元測試

[英]how to do unit testing for react-native applications

嗨,這是一個示例類,我想為其編寫單元

export default class testProject extends Component {

 _sum(a, b) {
      return a + b;
  } 

render() {
   return (
       <View>
            <Text>Business Finance</Text>
       </View>
          );
         }
}

我需要測試UI和Bussiness邏輯的哪些工具:)謝謝

經過一天的閱讀文檔,這個問題的答案很明確

對於UI-> Enzyme and Jest示例:->

    import Index from '../index.android.js';
    const expectedText = 'Business Finance';
    let wrapper=shallow(<Index />);
    expect(wrapper.find('Text').children().text()).toEqual(expectedText);

對於Businesslogic測試->酶

expect(wrapper.instance()._sum(2,3)).toBe(5);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM