Skip to content

Commit 48002c3

Browse files
siepramdjastrzebski
authored andcommitted
test: on null elements
1 parent 972d6e3 commit 48002c3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ test('toContainElement() passing null', () => {
8484
`);
8585
});
8686

87+
test('toContainElement() on null elements', () => {
88+
render(<View testID="view" />);
89+
90+
const view = screen.getByTestId('view');
91+
92+
expect(() => expect(null).toContainElement(view))
93+
.toThrowErrorMatchingInlineSnapshot(`
94+
"expect(received).toContainElement()
95+
96+
received value must be a host element.
97+
Received has value: null"
98+
`);
99+
});
100+
87101
test('toContainElement() on non-React elements', () => {
88102
render(<View testID="view" />);
89103

0 commit comments

Comments
 (0)