An open API service indexing awesome lists of open source software.

https://github.com/nvh95/jest-preview

Debug your Jest tests. Effortlessly.πŸ› πŸ–Ό
https://github.com/nvh95/jest-preview

angular css debug frontend javascript jest jest-view-html nextjs productivity react svelte test testing vue

Last synced: 11 days ago
JSON representation

Debug your Jest tests. Effortlessly.πŸ› πŸ–Ό

Awesome Lists containing this project

README

        




Jest Preview Logo


Jest Preview


Debug your Jest tests. Effortlessly. πŸ› πŸ–Ό


Jest Preview Demo


Try Jest Preview Online. No downloads needed!

[![All Contributors](https://img.shields.io/badge/all_contributors-33-orange.svg?style=flat-square)](#contributors-)

[![npm version](https://img.shields.io/npm/v/jest-preview)](https://www.npmjs.com/package/jest-preview)
[![npm total downloads](https://img.shields.io/npm/dt/jest-preview)](https://www.npmjs.com/package/jest-preview)
[![total GitHub stars](https://img.shields.io/github/stars/nvh95/jest-preview)](https://github.com/nvh95/jest-preview/stargazers)
[![Mentioned in Awesome Jest](https://awesome.re/mentioned-badge.svg)](https://github.com/jest-community/awesome-jest#debug)

[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)](./CONTRIBUTING.md)
[![Best of JS](https://img.shields.io/endpoint?url=https://bestofjs-serverless.now.sh/api/project-badge?fullName=nvh95%2Fjest-preview%26since=weekly)](https://bestofjs.org/projects/jest-preview)
[![Discord](https://img.shields.io/discord/967456149735637002?logo=discord&logoColor=ffffff&style=flat-square)](https://discord.gg/z4DRBmk7vx)

[![Try Jest Preview now](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/jest-preview?file=src%2FApp.test.tsx,README.md)

_Using Vitest? Try [Vitest Preview](https://github.com/nvh95/vitest-preview)_

## Why **jest-preview**

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` previews your Jest tests right in a browser, then you can see your actual UI visually, which helps you write and debug Jest tests faster.

`jest-preview` is initially designed to work with [Jest](https://jestjs.io/) and [react-testing-library](https://testing-library.com/docs/react-testing-library/intro/). The package is framework-agnostic, and you can use it with any frontend frameworks and testing libraries. For examples:

- [Vite React](https://www.jest-preview.com/docs/examples/vite-react)
- [Create React App](https://www.jest-preview.com/docs/examples/create-react-app)
- [Nextjs](https://www.jest-preview.com/docs/examples/nextjs)
- [Svelte](https://www.jest-preview.com/docs/examples/svelte)
- [Angular](https://www.jest-preview.com/docs/examples/angular)
- [Vue](https://www.jest-preview.com/docs/examples/vue)

## Features

- πŸ‘€ Preview your actual app's HTML in a browser in milliseconds.
- πŸ”„ Auto reload browser when executing `preview.`debug()`.
- πŸ’… Support CSS:
- βœ… [Direct CSS import](#3-configure-jests-transform-to-intercept-css-and-files)
- βœ… Number of CSS-in-JS libraries, such as:
- βœ… [Styled-components](https://styled-components.com/)
- βœ… [Emotion](https://emotion.sh/)
- βœ… [Global CSS](https://www.jest-preview.com/docs/getting-started/installation#4-optional-configure-global-css)
- βœ… [CSS Modules](https://github.com/css-modules/css-modules)
- βœ… [Sass](https://sass-lang.com/)
- πŸŒ„ Support viewing images.

## How to use `jest-preview` in 2 lines of code

```diff
+import preview from 'jest-preview';

describe('App', () => {
it('should work as expected', () => {
render();
+ preview.debug();
});
});
```

Or:

```diff
+import { debug } from 'jest-preview';

describe('App', () => {
it('should work as expected', () => {
render();
+ debug();
});
});
```

You also need to start the Jest Preview Server by running the CLI `jest-preview`. Please continue to read [Usage](https://www.jest-preview.com/docs/getting-started/usage) for the details instructions.

## Feedback

Your feedback is very important to us. Please help `jest-preview` becomes a better software by submitting feedback [here](https://forms.gle/PJFH5oEzi7gsb7Ac6).

## Installation

See the [Installation Guide](https://www.jest-preview.com/docs/getting-started/installation) on Jest Preview official website.

## Usage

See the [Usage Guide](https://www.jest-preview.com/docs/getting-started/usage) on Jest Preview official website.

## Advanced configurations

Jest Preview comes with [Pre-configured transformation](https://www.jest-preview.com/docs/getting-started/installation#2-configure-jests-transform-to-transform-css-and-files). However, in more advanced use cases where you have custom code transformation, check out the [Code Transformation Guide](https://www.jest-preview.com/docs/advanced-guides/code-transform).

## Upcoming features

- Support more `css-in-js` libraries.
- Multiple previews.
- [You name it](https://github.com/nvh95/jest-preview/labels/feature_request).

## Support

Please [file an issue](https://github.com/nvh95/jest-preview/issues), or [add a new discussion](https://github.com/nvh95/jest-preview/discussions) if you encounter any issues.

You can also mention [@JestPreview](https://twitter.com/JestPreview) or [@hung_dev](https://twitter.com/hung_dev) on Twitter if you want to have some more discussions or suggestions.

We also have a Discord server: [![Discord](https://img.shields.io/discord/967456149735637002?logo=discord&logoColor=ffffff&style=flat-square)](https://discord.gg/z4DRBmk7vx)

## Contributing

We can't wait to see your contributions. See the Contribution Guide at [CONTRIBUTING.md](/CONTRIBUTING.md)

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):



Hung Viet Nguyen
Hung Viet Nguyen

πŸ’» πŸ“– πŸ’‘
Truong Nguyen
Truong Nguyen

πŸ’» πŸ“– πŸ’‘
Viet Huu Doan
Viet Huu Doan

🎨
HarveyNguyen
HarveyNguyen

⚠️
Matt Murphy
Matt Murphy

πŸ“–
Traitanit Huangsri
Traitanit Huangsri

πŸ’»
Thanh Son Nguyen
Thanh Son Nguyen

πŸ’» πŸ’‘ πŸ“–


Minh Nguyen
Minh Nguyen

πŸ“–
Kyle(Tình Vũ)
Kyle(Tình Vũ)

πŸ›
Makoto Tateno
Makoto Tateno

πŸ“–
Abhishek Rawat
Abhishek Rawat

πŸ“–
Huynh Duc Duy
Huynh Duc Duy

πŸ’»
Nuno Casteleira
Nuno Casteleira

πŸ›
sundaycrafts
sundaycrafts

πŸ’»


LunduoCai
LunduoCai

πŸ›
huyenuet
huyenuet

⚠️
Bennett Dams
Bennett Dams

πŸ“–
Steven Rosato
Steven Rosato

πŸ’‘ πŸ›
nhducit
nhducit

πŸ€”
Benoit GRASSET
Benoit GRASSET

πŸ›
Sergii Kirianov
Sergii Kirianov

πŸ“– πŸ–‹ πŸ’»


Kim, Harim
Kim, Harim

πŸ“–
Lars Gyrup Brink Nielsen
Lars Gyrup Brink Nielsen

πŸ“– πŸ’‘
Mike Shi
Mike Shi

πŸ“–
Veniamin Krol
Veniamin Krol

πŸ“–
Ikko Ashimine
Ikko Ashimine

πŸ’»
Pavel Shut
Pavel Shut

πŸ›
David Z Hao
David Z Hao

πŸ›


Rohitbels
Rohitbels

πŸ’»
Rivaldi Putra
Rivaldi Putra

πŸ“–
Long Zhao
Long Zhao

πŸ’»
Justin Sun
Justin Sun

🌍
DΓ‘niel KΓ‘ntor
DΓ‘niel KΓ‘ntor

πŸ’»

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!

## Star history

[![Star History Chart](https://api.star-history.com/svg?repos=nvh95/jest-preview&type=Date)](https://star-history.com/#nvh95/jest-preview&Date)

## License

![This is open source software](https://user-images.githubusercontent.com/8603085/161439058-98faea42-c6e6-46f4-9ce6-218fad5f3b9a.gif)

MIT

## Sponsors

Your financial support helps the project alive and in a development mode. Make an impact by sponsoring us **$1** via [Open Collective](https://opencollective.com/jest-preview).

- Bronze Sponsor πŸ₯‰:
- Your company's logo/ profile picture on **README.md** and [www.jest-preview.com](https://www.jest-preview.com)
- Silver Sponsor πŸ₯ˆ:
- All of these above
- Your requests will be prioritized.
- Gold Sponsor πŸ₯‡:
- All of these above
- Let's discuss your benefits for this tier, please contact [the author](https://twitter.com/hung_dev)
- Diamond Sponsor πŸ’Ž:
- All of these above
- Let's discuss your benefits for this tier, please contact [the author](https://twitter.com/hung_dev)

### Bronze Sponsors πŸ₯‰






# Past Sponsors