Skip to content

Commit 2cd17d3

Browse files
authoredJul 28, 2020
fix: Suggest using toBeEmptyDOMElement instead of toBeEmpty (#284)
* Suggest using toBeEmptyDOMElement instead of toBeEmpty * fixed toBeEmptyDOMElement regular expression
1 parent 51ed5bf commit 2cd17d3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
 

‎src/__tests__/to-have-text-content.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ describe('.toHaveTextContent', () => {
8383
)
8484
})
8585

86-
test('when matching with empty string and element with content suggest using toBeEmpty instead', () => {
86+
test('when matching with empty string and element with content, suggest using toBeEmptyDOMElement instead', () => {
8787
// https://github.com/testing-library/jest-dom/issues/104
8888
const {container} = render('<span>not empty</span>')
8989

9090
expect(() =>
9191
expect(container.querySelector('span')).toHaveTextContent(''),
92-
).toThrowError(/toBeEmpty()/)
92+
).toThrowError(/toBeEmptyDOMElement\(\)/)
9393
})
9494
})

‎src/to-have-text-content.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function toHaveTextContent(
2525
'',
2626
),
2727
checkingWithEmptyString
28-
? `Checking with empty string will always match, use .toBeEmpty() instead`
28+
? `Checking with empty string will always match, use .toBeEmptyDOMElement() instead`
2929
: `Expected element ${to} have text content`,
3030
checkWith,
3131
'Received',

0 commit comments

Comments
 (0)
Please sign in to comment.