<SingleDatePicker
date={this.state.createdAt}
onDateChange={this.onDateChange}
focused={this.state.calendarFocused}
onFocusChange={this.onFocusChange}
numberOfMonths={1}
isOutsideRange={() => false}/>
this is my component
and I want to access SingleDatePicker in my jest test file like
wrapper.find('singleDatePicker')
its not showning up.
But there are other inputs are also present in the form which are showing up by this line i.e
wrapper.find('input')
@bilal68 using a string is a bit less robust than just importing the component in your test because it compares against the display name. If you do
import { SingleDatePicker } from 'react-dates';
it('', () => {
const wrapper = ...;
expect(wrapper.find(SingleDatePicker)).to.have.lengthOf(1);
});
that should work.
I think technically the display name of the component is now withStyles(SingleDatePicker).
Separately, the name is "SingleDatePicker", not "singleDatePicker" - note the capitalization.
Most helpful comment
@bilal68 using a string is a bit less robust than just importing the component in your test because it compares against the display name. If you do
that should work.
I think technically the display name of the component is now
withStyles(SingleDatePicker).