Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggest using toBeEmptyDOMElement instead of toBeEmpty #284

Merged

Conversation

brrianalexis
Copy link
Member

What:

Suggest using toBeEmptyDOMElement instead of toBeEmpty.

Why:

Since PR #254 we are deprecating toBeEmpty in favour of toBeEmptyDOMElement, so we should suggest using it instead.

How:

When checking with an empty string using toHaveTextContent, the following error message is displayed:

Checking with empty string will always match, use .toBeEmpty() instead

In this PR I changed it to:

Checking with empty string will always match, use .toBeEmptyDOMElement() instead

Checklist:

  • [ N/A] Documentation
  • Tests
  • [ N/A] Updated Type Definitions
  • Ready to be merged

@codecov
Copy link

codecov bot commented Jul 27, 2020

Codecov Report

Merging #284 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #284   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           23        23           
  Lines          315       315           
  Branches        72        72           
=========================================
  Hits           315       315           
Impacted Files Coverage Δ
src/to-have-text-content.js 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 51ed5bf...917aa6c. Read the comment docs.

@@ -83,7 +83,7 @@ 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', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why the toThrowError line below did not have to be changed as well. Shouldn't the expected error message change to /toBeEmptyDOMElement()/?

I think it's because there's a mistake in that regular expression. Those parenthesis are not being matched but they are interpreted as an empty group. Can you please change that regexp to be /toBeEmptyDOMElement\(\)/?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. It slipped past me.

I just changed it. Thanks!

@gnapse gnapse merged commit 2cd17d3 into testing-library:master Jul 28, 2020
@brrianalexis brrianalexis deleted the suggest-toBeEmptyDOMElement branch July 28, 2020 18:14
@gnapse
Copy link
Member

gnapse commented Jul 28, 2020

🎉 This PR is included in version 5.11.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants