Introduction
Meet Jest Previewâ
We are sure you are tired of debugging integration UI tests and reading a whole lot of cryptic HTML output. It's incredibly tough to visualize the DOM structure and see what went wrong and why. We are sure because we were there. That's why we have created Jest Preview!
Jest Preview is an open-source library to make your life easier. See your test output directly in the browser as you would normally see the app you are working on. Write test and watch rendered output changes accordingly. Jest Preview lets you concentrate on tests in the "real world" rather than deciphering HTML code. Sounds interesting? Sure it does! Give it a try đ
đ continue reading to know more and try Jest Preview in action
You can go straight to Installation guide to install it locally on your machine.
Featuresâ
- đŖ It's incredibly simple to install and use!
- đ Preview your actual app's HTML in a browser in milliseconds.
- đ Auto reload browser when executing
preview.debug()
. - đ
Support CSS:
- â Direct CSS import
- â
Number of CSS-in-JS libraries, such as:
- â Styled-components
- â Emotion
- â Global CSS
- â CSS Modules
- â Sass
- đ Support viewing images.
- đ§âđģ Our contributors work hard to add more features and provide support âī¸
Would like to contribute? Great! We appreciate it a lot! Check our Contributing section đ
Online Demoâ
Want to try the library before installing it? We got you covered! Check out StackBlitz Demo App or try it right here đ
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 library.
How to use Jest Preview with only 2 lines of codeâ
Start the Jest Preview Server by running the CLI command jest-preview
. To make it look even better, follow the Installation guide
+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();
});
});