Skip to content

Commit

Permalink
fix: Suggest using toBeEmptyDOMElement instead of toBeEmpty (#284)
Browse files Browse the repository at this point in the history
* Suggest using toBeEmptyDOMElement instead of toBeEmpty
* fixed toBeEmptyDOMElement regular expression
  • Loading branch information
brrianalexis committed Jul 28, 2020
1 parent 51ed5bf commit 2cd17d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/__tests__/to-have-text-content.js
Expand Up @@ -83,12 +83,12 @@ describe('.toHaveTextContent', () => {
)
})

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

expect(() =>
expect(container.querySelector('span')).toHaveTextContent(''),
).toThrowError(/toBeEmpty()/)
).toThrowError(/toBeEmptyDOMElement\(\)/)
})
})
2 changes: 1 addition & 1 deletion src/to-have-text-content.js
Expand Up @@ -25,7 +25,7 @@ export function toHaveTextContent(
'',
),
checkingWithEmptyString
? `Checking with empty string will always match, use .toBeEmpty() instead`
? `Checking with empty string will always match, use .toBeEmptyDOMElement() instead`
: `Expected element ${to} have text content`,
checkWith,
'Received',
Expand Down

0 comments on commit 2cd17d3

Please sign in to comment.