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

feat(debug): add a debug convenience method #87

Merged
merged 1 commit into from
May 15, 2018
Merged

Conversation

kentcdodds
Copy link
Member

What: add a debug convenience method

Also add @Gpx to contributors!

Why:

Closes #86

How:

  • Just re-export everything from dom-testing-library to simplify maintainence
  • Add a simple debug method to make it really easy to log the container.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged
  • Added myself to contributors table

Also adds @Gpx to contributors!

Closes #86
@@ -62,7 +62,8 @@
"extends": "./node_modules/kcd-scripts/eslint.js",
"rules": {
"react/prop-types": "off",
"import/no-unassigned-import": "off"
"import/no-unassigned-import": "off",
"import/named": "off"
Copy link
Member Author

Choose a reason for hiding this comment

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

This is necessary because we're using export * from 'dom-testing-library' in the index.js and I don't think that eslint-plugin-import knows how to deal with that so it was erroring out when we imported things that come from dom-testing-library. Kinda annoying, but I'd rather use the export *, and I verified that it works for consumers of the library so we're good.

@Gpx
Copy link
Member

Gpx commented May 15, 2018

Wow, this was quick! Any help needed?

@codecov
Copy link

codecov bot commented May 15, 2018

Codecov Report

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

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #87   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines          16     17    +1     
=====================================
+ Hits           16     17    +1
Impacted Files Coverage Δ
src/index.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 ad4627a...03cb1b6. Read the comment docs.

@kentcdodds
Copy link
Member Author

Thanks @Gpx. Nope. Sorry, normally I would have let you work on this, but I needed to code this for my own well being (I was feeling very demotivated to do any work yesterday, this was a task I could do and feel accomplished). Thanks!

@kentcdodds kentcdodds merged commit de769ec into master May 15, 2018
@kentcdodds kentcdodds deleted the pr/pretty-dom branch May 15, 2018 15:52
@kentcdodds
Copy link
Member Author

🎉 This PR is included in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Gpx
Copy link
Member

Gpx commented May 15, 2018

Hoped it helped. It's definitely going to be useful to me 🎉

julienw pushed a commit to julienw/react-testing-library that referenced this pull request Dec 20, 2018
…rary#87)

**What**:

Changes the way `getNodeText` joins nodes. Instead of joining them with a space, it now joins them with an empty string.

<!-- Why are these changes necessary? -->

**Why**:

This PR comes out of testing-library#53

In React, if you have an element like `<span>{volts}V</span>`, then the generated element will have two text nodes, one for the variable `volts`, and one for the normal string.

When browsers render this, there is no space between the text nodes. Likewise, the `textContent` property on the span will return a string without spaces (e.g. `300V`).

However, the current implementation of `getNodeText` joins all of the nodes with a space, so if you try to use e.g. `queryByText('300V')` it will return `null`.

For a live demo, see https://codesandbox.io/s/w718n5ojq7

<!-- How were these changes implemented? -->

**How**:

- changing `join(' ')` to `join('')` on [line 8 of `src/get-node-text.js`](https://github.com/kentcdodds/dom-testing-library/compare/master...bdchauvette:pr/get-node-text-whitespace?expand=1#diff-6350d468f7684d134aab9d42d96a77beR8)
- adding [a test](https://github.com/kentcdodds/dom-testing-library/compare/master...bdchauvette:pr/get-node-text-whitespace?expand=1#diff-de31c4d0bed96b2a4211de164bb1b589R59) for querying against a DOM element containing adjacent text nodes without any whitespace

<!-- Have you done all of these things?  -->

**Checklist**:

<!-- add "N/A" to the end of each line that's irrelevant to your changes -->

<!-- to check an item, place an "x" in the box like so: "- [x] Documentation" -->

- [ ] Documentation - **N/A** (I think?)
- [x] Tests
- [x] Ready to be merged <!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->
- [x] Added myself to contributors table <!-- this is optional, see the contributing guidelines for instructions -->

<!-- feel free to add additional comments -->

Thanks! 😸 

Closes testing-library#53
lucbpz pushed a commit to lucbpz/react-testing-library that referenced this pull request Jul 26, 2020
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.

None yet

2 participants