0

试图开玩笑react-native-copilot

这是屏幕中导入模块的点。

import { walkthroughable, CopilotStep } from 'react-native-copilot';
...
const CopilotText = walkthroughable(Text);
...
<View>
  <CopilotStep order={2} name='name'>
    <CopilotText testID={'test-schedule-name'}>
      {this.props.scheduleName}
    </CopilotText>
  </CopilotStep>
</View>
...

到目前为止,这是在测试中模拟它的方式:

jest.mock('react-native-copilot', () => ({
  getCurrentStep: jest.fn(() => { }),
}));

这是测试:

it('displays name', () => {
    const { getByTestId } = render(<MyComponent />);
    const scheduleName = getByTestId('test-schedule-name'); // it doesn't get this... why? 
    ...
});

这是错误:

Unable to find an element with testID: test-schedule-name
...
const CopilotText = walkthroughable(Text);
                    ^

任何想法?

4

0 回答 0