score:0

it depends which test runner or assertion library you are using.

for jest you want to use tohavelength

it('contains a table', () => {
  const wrapper = mount(<transactionstable />);
  expect(wrapper.find(pagination)).tohave.lengthof(1);
});

where as chai would be to.have.lengthof(1)

score:2

i suppose that the error, you've got after you have used a valid matcher appears because enzyme cannot find pagination component in transactionstable. tohavelength jest matcher gives strange output when it fails while being used with enzyme wrapper. try to use the following statement

expect(wrapper.find(pagination).length).tobe(1);

and i bet you will get an error that the expected value is 1 but 0 received.

ps: here is the issue in jest repo about the strange output.


Related Query

More Query from same tag