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
npm install jest-serializer-html
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
52 Stars
44 Commits
8 Forks
51 Watching
10 Branches
258 Contributors
Updated on 07 Aug 2024
JavaScript (62.84%)
Shell (37.16%)
Cumulative downloads
Total Downloads
Last day
0%
198,013
Compared to previous day
Last week
4.1%
1,019,623
Compared to previous week
Last month
17.7%
4,222,790
Compared to previous month
Last year
132.4%
34,789,041
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
56 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
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