I have this test:
const rendered = render(
<TransactionReason
reason={{ code: defaultReason }}
/>
);
expect(rendered.getByTestId('reasonInput')).toBeNull();
What I'm trying to do is: there is a component that has the testID = 'reasonInput'
, but this component is not rendered when the reason
prop has that value that I'm giving (code: defaultReason). But I get an error because Jest can't find that id, of course, is not rendered. I thought that that would produce a false or null value, that's why I tried with toBeNull
or toBeFalsy
or something like that.
How could I then test the not existance of that component?