How to test async function with spyOn?
问题 I am trying to test an async function in a react native app. class myClass extends React.Component { ... closeModal = async () => { if (someCondition) { await myFunction1(); } else { await myFunction2(); } this.props.navigation.state.params.onGoBack(); this.props.navigation.navigate('Main'); }; ... } This is my test: const navigation = { navigate: jest.fn(), state: { params: { onGoBack: jest.fn() } }, }; const renderComponent = overrides => { props = { navigation, ...overrides, }; return