Open mtoninelli opened 3 years ago
This works if you wrap the component in a copilot
before using in the test:
import { render } from '@testing-library/react-native';
import React from 'react';
import { View, Text } from 'react-native';
import { walkthroughable, CopilotStep, copilot } from 'react-native-copilot';
const CopilotText = walkthroughable(Text);
function Thing() {
return (
<View>
<CopilotStep order={2} name='name' text='hello there'>
<CopilotText testID={'test-schedule-name'}>Some name</CopilotText>
</CopilotStep>
</View>
);
}
export const WrappedThing = copilot({})(Thing);
it('should do the thing', () => {
const { getByText } = render(<WrappedThing />);
const text = getByText('Some name');
expect(text).toBeTruthy();
});
It also sees both the test ID and the text, so I think it's just an issue with how your test is set up.
Current Behavior Testing with
@testing-library/react-native
the CopilotText element is not foundInput Code
The test
Expected behavior/code Be able to select the CopilotText as the Text do
Environment
react-native-copilot
: [e.g. v2.4.6]react-native
: 0.59.0react-native-svg
: 9.11.1Possible Solution Another way of mocking the module (?)