Skip to content

Commit cb3ef7e

Browse files
siepramdjastrzebski
authored andcommitted
test: passing null as argument
1 parent 225ec96 commit cb3ef7e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/matchers/__tests__/to-contain-element.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,28 @@ test('toContainElement() on parent view', () => {
3232
`);
3333
});
3434

35+
test('toContainElement() passing null', () => {
36+
render(<View testID="view" />);
37+
38+
const view = screen.getByTestId('view');
39+
40+
expect(view).not.toContainElement(null);
41+
42+
expect(() => expect(view).toContainElement(null))
43+
.toThrowErrorMatchingInlineSnapshot(`
44+
"expect(element).toContainElement(element)
45+
46+
<View
47+
testID="view"
48+
/>
49+
50+
does not contain:
51+
52+
null
53+
"
54+
`);
55+
});
56+
3557
test('toContainElement() on non-React elements', () => {
3658
render(<View testID="view" />);
3759

0 commit comments

Comments
 (0)