react-testing-library version: 5.0.0react version: 16.4.2node version: 8.11.3npm (or yarn) version: 6.4.0 const Test = () => (
<div>
<div>hi</div>
<div>other</div>
</div>
)
const container = rtl.render(Test)
console.log(container.debug())
ran this in a test
running test in a jsdom environment
undefined (debug doesn't do anything)
docs imply debug() does something :)
You don't need the console.log. debug() does the log for you.
const spy = jest.spyOn(console, 'log')
container.debug()
spy.mockRestore()
console.log(spy.mock.calls)
logs []
import * as dom from 'dom-testing-library'
console.log(dom.prettyDOM(container.baseElement))
prints out the element tree.
I also copied from dist this code:
Object.keys(_domTestingLibrary).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _domTestingLibrary[key];
}
});
});
console.log(((0, _domTestingLibrary.prettyDOM)(container.baseElement)))
and that prints out. This is a weird bug, not sure what is going on
Hmmmm.... I'm not sure what's going on, but here's the code for it... It's pretty simple:
https://github.com/kentcdodds/react-testing-library/blob/master/src/index.js#L25
It's working for me 🤷♂️
@cellog can you provide an example repo that reproduces the problem?
Most helpful comment
You don't need the
console.log.debug()does the log for you.