0

Having following code:

  it('componentDidUpdate should mount and change props', () => {
    const onChange = jest.fn();
    const wrapper = enzyme
      .mount(
          <JsonInput
            onChange={onChange}
            onValueChange={mockOnValueChange}
            value={exampleJsonStringValidated}
          />,
          { wrappingComponent: withTestThemeWrapper },
      );
    expect(wrapper.find(JsonInput).hasClass(':valid')).toEqual(false);
    wrapper.setProps({ value: exampleJsonStringNotValidated });
    expect(wrapper.find(JsonInput).hasClass(':invalid')).toBe(false);
  });

Gave me:

TypeError: Cannot read property 'target' of null

I was trying to pass onChange as onChange and onChange() but does not work.

I would appreciate any help.

Hamza El Aoutar
  • 5,292
  • 2
  • 17
  • 23
Tomasz Waszczyk
  • 2,680
  • 5
  • 35
  • 73

1 Answers1

0

Try:

wrapper.props().value = exampleJsonStringNotValidated;

If not, I would appreciate it if you post your component code and the props.

Zaki Obeid
  • 61
  • 3