This repository was archived by the owner on Jul 30, 2020. It is now read-only.
This repository was archived by the owner on Jul 30, 2020. It is now read-only.
*ByDisplayValue doesn't work for Switch #56
Closed
Description
react-native
orexpo
: 'react-native'native-testing-library
version: 4.0.9jest-preset
: @testing-library/react-nativereact-native
version: 60.5node
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!
Metadata
Metadata
Assignees
Labels
No labels