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

Refactor custom matchers #1

Merged
merged 3 commits into from
Apr 6, 2018
Merged

Refactor custom matchers #1

merged 3 commits into from
Apr 6, 2018

Conversation

gnapse
Copy link
Member

@gnapse gnapse commented Apr 6, 2018

(re-creating testing-library/react-testing-library#46)

This is a proposed refactor to the custom matchers code, as briefly discussed in testing-library/react-testing-library#44 (comment):

  • Use common message format across all custom matchers
  • Make it easy to adopt the same format in any future matchers
  • Simplify code, remove unneeded if/else logic

Closes #45

Proposed changes not yet performed (pending discussion)

  • Make each custom matcher a named export, instead of bundling them in an object as default export
  • Better organize in a sub folder with one file per matchers and some utils file for common stuff

Pending to be fixed

  • Code coverage is not full because getDisplayName never gets called during the tests with a class as argument, only with html elements. I wonder if that is expected, given that this library is only dealing with rendered html and not the virtual dom, or is it?

@codecov
Copy link

codecov bot commented Apr 6, 2018

Codecov Report

Merging #1 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master     #1   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           5      5           
  Lines          91     85    -6     
  Branches       22     24    +2     
=====================================
- Hits           91     85    -6
Impacted Files Coverage Δ
src/jest-extensions.js 100% <100%> (ø) ⬆️

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 f19e276...e141566. Read the comment docs.

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

I love this. Thanks!

@kentcdodds kentcdodds merged commit e6efd07 into testing-library:master Apr 6, 2018
@gnapse gnapse deleted the pr/refactor-custom-matchers branch April 6, 2018 14:16
@kentcdodds
Copy link
Member

🎉 This PR is included in version 1.1.0 🎉

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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants