Debug your Jest tests. Effortlessly. 🛠🖼
Try Jest Preview Online. No downloads needed!
When writing tests using Jest, we usually debug by reading the HTML code. Sometimes, the HTML is too complicated to visualize the UI in our head. jest-preview
initiates a server and serve your HTML in a browser, then you can see your actual UI visually, which helps you debug jest tests faster.
jest-preview
is initially designed to work with jest and react-testing-library. The package is framework-agnostic, and you can use it with any testing libraries.
- 👀 Preview your actual app's HTML in a browser in milliseconds.
- 🔄 Auto reload browser when execute
preview.debug()
. - 💅 Support CSS:
- ✅ Direct CSS import
- ✅ Number of CSS-in-JS libraries, such as:
- ✅ Global CSS
- ✅ CSS Modules
- ✅ Sass
- 🌄 Support viewing images.
+import preview from 'jest-preview';
describe('App', () => {
it('should work as expected', () => {
render(<App />);
+ preview.debug();
});
});
Or:
+import { debug } from 'jest-preview';
describe('App', () => {
it('should work as expected', () => {
render(<App />);
+ debug();
});
});
You also need to start the Jest Preview Server by running the CLI jest-preview
. Please continue to read Usage for the details instructions.
- Use with Vite React: https://www.jest-preview.com/docs/examples/vite-react
- Use with Create React App: https://www.jest-preview.com/docs/examples/create-react-app
- Use with Next.js Rust Compiler: https://www.jest-preview.com/docs/examples/next-rust
- Use with Next.js Babel: https://www.jest-preview.com/docs/examples/next-babel
- Use with Svelte: https://www.jest-preview.com/docs/examples/svelte
Your feedback is very important to us. Please help jest-preview
becomes a better software by submitting a feedback here.
See the Installation Guide on Jest Preview official website.
See the Usage Guide on Jest Preview official website.
Jest Preview comes with Pre-configured transformation. However, in more advanced use cases where you have custom code transformation, check out the Code Transformation Guide.
- Support more
css-in-js
libraries. - Multiple preview.
- You name it.
Please file an issue, or add a new discussion if you encounter any issues.
You can also mention @JestPreview or @hung_dev on twitter if you want to have some more discussions or suggestions.
We also have a Discord server:
We can't wait to see your contributions. See the Contribution Guide at CONTRIBUTING.md
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
MIT
If you like the project and want us continue to develop it, please sponsor us via Open Collective, starting from $1.
Bronze Sponsor 🥉 and Silver Sponsor 🥈 on Open Collective will have your logo on README.md and www.jest-preview.com, for the Gold Sponsor 🥇 and Diamond Sponsor 💎, please contact the author.