This repository was archived by the owner on Jul 30, 2020. It is now read-only.

Description
react-native or expo: 'react-native'
native-testing-library version: 4.0.9
jest-preset: @testing-library/react-native
react-native version: 60.5
node version: 10.15.1
Relevant code or config:
const Switch = ({ value, onValueChange }: {value: string; onValueChange(): void) => {
return (<Switch value={value} onValueChange={onValueChange} />);
}
it('should work as expected', () => {
const callback = jest.fn();
const { getByDisplayValue } = render(<Switch value={false} onValueChanged={callback} />)
expect(getByDisplayValue('false')).toBeTruthy()
})
What you did:
Tried to write a test for a component with a Switch in it.
What happened:
getByDisplayValue is expecting a Matcher(string | RegExp), so you can't pass in false, 'false' as a string also doesn't seem to work.
I also tried to ignore the Typescript error and pass false (and 'off') to getByDisplayValue with no luck.
Component output from debug
<Text
style={
Object {
"paddingBottom": 4,
"paddingEnd": 12,
"paddingTop": 4,
}
}
>
testLabel
</Text>
<Switch
testID="id"
value={false}
/>
Problem description:
The documentation indicates that ByDisplayValue is what we should be using for switches.
Am I missing something?
Can you help us fix this issue by submitting a pull request?
Possibly, if I can get some direction as to what the intended behaviour is supposed to be!