Hil,
I would like to complete the following snapshot test but I don't know how to pass in state which is required for the page to render.
test('test renders as per snapshot', () => {
const state = {
orderNumber: 1000000001,
userID: 1234567,
}
const tree = renderer
.create(<Order location={ state }></Order>)
.toJSON();
expect(tree).toMatchSnapshot();
});
I get this error
TypeError: Cannot read property 'orderNumber' of undefined
> 40 | this.props.location.state.orderNumber;
Can someone please tell me how I can pass this to my snapshot test so it doesnt fail?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…