Gathering detailed insights and metrics for jest-serializer-html
Gathering detailed insights and metrics for jest-serializer-html
Gathering detailed insights and metrics for jest-serializer-html
Gathering detailed insights and metrics for jest-serializer-html
jest-serializer
> DEPRECATED: Use `v8` APIs directly: https://nodejs.org/api/v8.html#serialization-api
diffable-html
Opinionated HTML formatter focused towards making HTML diffs readable.
jest-serializer-html-string
A better Jest snapshot serializer for plain html strings
@hjkcai/jest-serializer-html
A superb jest serializer for html strings
npm install jest-serializer-html
Typescript
Module System
Node Version
NPM Version
JavaScript (62.84%)
Shell (37.16%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
53 Stars
44 Commits
8 Forks
50 Watchers
10 Branches
263 Contributors
Updated on Apr 06, 2025
Latest Version
7.1.0
Package Id
jest-serializer-html@7.1.0
Unpacked Size
6.81 kB
Size
2.49 kB
File Count
5
NPM Version
6.14.8
Node Version
12.19.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
2
When using this Jest serializer, it will turn any string starting with '<' to nicely indented HTML in the snapshot.
This serializer is based on diffable-html which is an opinionated HTML formatter that will ease readability of diffs in case of failing snapshot tests.
Add the package as a dev-dependency:
1# With npm 2npm install --save-dev jest-serializer-html 3 4# With yarn 5yarn add --dev jest-serializer-html
Update package.json to let Jest know about the serializer:
1"jest": { 2 "snapshotSerializers": ["jest-serializer-html"] 3}
1test('should beautify HTML', () => { 2 expect('<ul><li><a href="#">My HTML</a></li></ul>').toMatchSnapshot(); 3});
Will output:
1exports[`should beautify HTML 1`] = ` 2<ul> 3 <li> 4 <a href="#"> 5 My HTML 6 </a> 7 </li> 8</ul> 9`;
1import Vue from 'vue'; 2const Hello = { 3 props: { 4 msg: { 5 type: String, 6 default: 'World' 7 } 8 }, 9 template: ` 10 <h1>Hello ${ msg }!</h1> 11 <ul id="main-list" class="list"><li><a href="#">My HTML</a></li></ul> 12 ` 13}; 14 15test('should beautify HTML', () => { 16 const Component = Vue.extend(Hello); 17 const vm = new Component({ 18 propsData: { 19 msg: 'You' 20 } 21 }); 22 23 vm.$mount(); 24 25 expect(vm.$el.outerHTML).toMatchSnapshot(); 26});
Will output:
1exports[`should beautify HTML 1`] = ` 2<h1> 3 Hello You! 4</h1> 5<ul id="main-list" 6 class="list" 7> 8 <li> 9 <a href="#"> 10 My HTML 11 </a> 12 </li> 13</ul> 14`;
You can read more about the HTML formatting here.
This package was inspired by the amazing post here: Jest for all: Episode 1 — Vue.js by Cristian Carlesso.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 3/19 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
58 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More