-
Notifications
You must be signed in to change notification settings - Fork 277
Closed
Description
I wrote this test and it worked perfectly
describe('test', () => {
it( 'should render all text', () => {
const {getByText, getByTestId, debug} = render(
<View>
<View><Text>test1</Text></View>
<View><Text>test2</Text></View>
<View><Text>test3</Text></View>
</View>
});
});
I wanted to test each text alone so I edited the code to be like this .. I expected to work but it gave me this error
describe('test', () => {
const {getByText, debug} = render(
<View>
<View><Text>test1</Text></View>
<View><Text>test2</Text></View>
<View><Text>test3</Text></View>
</View>
});
it('should render test1', () => {
debug();
expect(getByText('test1')).toBeTruthy();
});
it('should render test2', () => {
debug(); // return null
expect(getByText('test2')).toBeTruthy(); // fails
});
it('should render test13, () => {
debug(); // return null
expect(getByText('test3')).toBeTruthy(); // fails
});
});
Versions
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5
react-native-testing-library: ^1.13.0 => 1.13.0
react-test-renderer: ^16.13.1 => 16.13.1
tsemerad, lauriharpf, Adan0031 and ckotkar
Metadata
Metadata
Assignees
Labels
No labels