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

fix: Improve toHaveClass error message format #405

Merged
merged 4 commits into from
Dec 6, 2021

Conversation

akrifari
Copy link
Contributor

@akrifari akrifari commented Oct 3, 2021

What:
This PR aims to make toHaveClass error message format to be more descriptive when exact option is set to true.

How:

  • Before:

      Expected the element to have EXACTLY defined classes
    
      alone foo:
        Received
      :
        undefined
    
        169 |   })
        170 |
      > 171 |   expect(queryByTestId('no-classes')).toHaveClass('alone', 'foo', {
            |                                       ^
        172 |     exact: true,
        173 |   })
        174 |
  • After:

      expect(element).toHaveClass("alone foo")
    
      Expected the element to have EXACTLY defined classes:
        alone foo
      Received:
    
        169 |   })
        170 |
      > 171 |   expect(queryByTestId('no-classes')).toHaveClass('alone', 'foo', {
            |                                       ^
        172 |     exact: true,
        173 |   })
        174 |

Checklist:

  • Ready to be merged

Related:
Close #397

@codecov
Copy link

codecov bot commented Oct 14, 2021

Codecov Report

Merging #405 (9f99f57) into main (6f69437) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #405   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           26        26           
  Lines          620       621    +1     
  Branches       227       228    +1     
=========================================
+ Hits           620       621    +1     
Impacted Files Coverage Δ
src/to-have-class.js 100.00% <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 6f69437...9f99f57. Read the comment docs.

@gnapse gnapse merged commit a9beb47 into testing-library:main Dec 6, 2021
@gnapse
Copy link
Member

gnapse commented Dec 6, 2021

@all-contributors, please add @akrifari for code

@github-actions
Copy link

github-actions bot commented Dec 6, 2021

🎉 This PR is included in version 5.16.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@akrifari akrifari deleted the improve-tohaveclass-message branch December 7, 2021 04:59
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.

toHaveClass(..., { exact: true })'s Received/Expected output is buggy
2 participants