Jest tools let you inspect html from your Jest tests with ease when logging to console is not enough.
- Install the VSCode extension.
- From VSCode's command palette, run the
Jest tools: Start jest tools
command. - This will show you the Jest tools UI. The initial screen will ask you to start Jest with additional command line arguments (A custom jest reporter to capture console logs).
- Then simply
console.log()
a html string and it will appear in the inspector.
Logging the entire body content after rendering a component.
import { render } from '@testing-library/react';
test('should work', () => {
render(<App />);
console.log(document.body.innerHtml); // this html will appear in jest tools
});
Thanks goes to these wonderful people (emoji key):
Raathi Kugarajan 💻 📖 🤔 🚇 🚧 |
This project follows the all-contributors specification. Contributions of any kind welcome!