Skip to content

Commit 4866194

Browse files
committed
test: prettify JSON snapshot
1 parent 49ce536 commit 4866194

File tree

2 files changed

+277
-3
lines changed

2 files changed

+277
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,278 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`CLI Formatter: json should have stdout output with formatter json 1`] = `
4-
"[{\\"file\\":\\"//HTMLHint//src//cli//formatters//__fixtures__//example.html\\",\\"messages\\":[{\\"type\\":\\"error\\",\\"message\\":\\"The value of attribute [ bad ] must be in double quotes.\\",\\"raw\\":\\" bad=''\\",\\"evidence\\":\\" <div bad='' bad=''></div>\\",\\"line\\":8,\\"col\\":7,\\"rule\\":{\\"id\\":\\"attr-value-double-quotes\\",\\"description\\":\\"Attribute values must be in double quotes.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/attr-value-double-quotes\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"The value of attribute [ bad ] must be in double quotes.\\",\\"raw\\":\\" bad=''\\",\\"evidence\\":\\" <div bad='' bad=''></div>\\",\\"line\\":8,\\"col\\":14,\\"rule\\":{\\"id\\":\\"attr-value-double-quotes\\",\\"description\\":\\"Attribute values must be in double quotes.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/attr-value-double-quotes\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"Duplicate of attribute name [ bad ] was found.\\",\\"raw\\":\\" bad=''\\",\\"evidence\\":\\" <div bad='' bad=''></div>\\",\\"line\\":8,\\"col\\":14,\\"rule\\":{\\"id\\":\\"attr-no-duplication\\",\\"description\\":\\"Elements cannot have duplicate attributes.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/attr-no-duplication\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"The value of attribute [ bad ] must be in double quotes.\\",\\"raw\\":\\" bad=''\\",\\"evidence\\":\\" <div bad='' bad=''></div>\\",\\"line\\":9,\\"col\\":7,\\"rule\\":{\\"id\\":\\"attr-value-double-quotes\\",\\"description\\":\\"Attribute values must be in double quotes.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/attr-value-double-quotes\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"The value of attribute [ bad ] must be in double quotes.\\",\\"raw\\":\\" bad=''\\",\\"evidence\\":\\" <div bad='' bad=''></div>\\",\\"line\\":9,\\"col\\":14,\\"rule\\":{\\"id\\":\\"attr-value-double-quotes\\",\\"description\\":\\"Attribute values must be in double quotes.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/attr-value-double-quotes\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"Duplicate of attribute name [ bad ] was found.\\",\\"raw\\":\\" bad=''\\",\\"evidence\\":\\" <div bad='' bad=''></div>\\",\\"line\\":9,\\"col\\":14,\\"rule\\":{\\"id\\":\\"attr-no-duplication\\",\\"description\\":\\"Elements cannot have duplicate attributes.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/attr-no-duplication\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"Tag must be paired, no start tag: [ </input> ]\\",\\"raw\\":\\"</input>\\",\\"evidence\\":\\" <input type=/\\"text/\\"></input>\\",\\"line\\":10,\\"col\\":22,\\"rule\\":{\\"id\\":\\"tag-pair\\",\\"description\\":\\"Tag must be paired.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/tag-pair\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"Special characters must be escaped : [ < ].\\",\\"raw\\":\\"/r/n <div class/\\"foo/\\">/r/n/r/n \\",\\"evidence\\":\\" <div class/\\"foo/\\">\\",\\"line\\":11,\\"col\\":3,\\"rule\\":{\\"id\\":\\"spec-char-escape\\",\\"description\\":\\"Special characters must be escaped.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/spec-char-escape\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"Special characters must be escaped : [ > ].\\",\\"raw\\":\\"/r/n <div class/\\"foo/\\">/r/n/r/n \\",\\"evidence\\":\\" <div class/\\"foo/\\">\\",\\"line\\":11,\\"col\\":18,\\"rule\\":{\\"id\\":\\"spec-char-escape\\",\\"description\\":\\"Special characters must be escaped.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/spec-char-escape\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"Tag must be paired, no start tag: [ </div> ]\\",\\"raw\\":\\"</div>\\",\\"evidence\\":\\" </div>\\",\\"line\\":13,\\"col\\":11,\\"rule\\":{\\"id\\":\\"tag-pair\\",\\"description\\":\\"Tag must be paired.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/tag-pair\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"Tag must be paired, no start tag: [ </div> ]\\",\\"raw\\":\\"</div>\\",\\"evidence\\":\\" </div>\\",\\"line\\":14,\\"col\\":9,\\"rule\\":{\\"id\\":\\"tag-pair\\",\\"description\\":\\"Tag must be paired.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/tag-pair\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"Tag must be paired, no start tag: [ </hello> ]\\",\\"raw\\":\\"</hello>\\",\\"evidence\\":\\" </hello>\\",\\"line\\":15,\\"col\\":7,\\"rule\\":{\\"id\\":\\"tag-pair\\",\\"description\\":\\"Tag must be paired.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/tag-pair\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"Tag must be paired, no start tag: [ </test> ]\\",\\"raw\\":\\"</test>\\",\\"evidence\\":\\" </test>\\",\\"line\\":16,\\"col\\":5,\\"rule\\":{\\"id\\":\\"tag-pair\\",\\"description\\":\\"Tag must be paired.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/tag-pair\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"Tag must be paired, no start tag: [ </div> ]\\",\\"raw\\":\\"</div>\\",\\"evidence\\":\\" </div>\\",\\"line\\":17,\\"col\\":3,\\"rule\\":{\\"id\\":\\"tag-pair\\",\\"description\\":\\"Tag must be paired.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/tag-pair\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"The value of attribute [ class ] must be in double quotes.\\",\\"raw\\":\\" class=''\\",\\"evidence\\":\\" <div class='' what='' something=''></div>\\",\\"line\\":21,\\"col\\":15,\\"rule\\":{\\"id\\":\\"attr-value-double-quotes\\",\\"description\\":\\"Attribute values must be in double quotes.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/attr-value-double-quotes\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"The value of attribute [ what ] must be in double quotes.\\",\\"raw\\":\\" what=''\\",\\"evidence\\":\\" <div class='' what='' something=''></div>\\",\\"line\\":21,\\"col\\":24,\\"rule\\":{\\"id\\":\\"attr-value-double-quotes\\",\\"description\\":\\"Attribute values must be in double quotes.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/attr-value-double-quotes\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"The value of attribute [ something ] must be in double quotes.\\",\\"raw\\":\\" something=''\\",\\"evidence\\":\\" <div class='' what='' something=''></div>\\",\\"line\\":21,\\"col\\":32,\\"rule\\":{\\"id\\":\\"attr-value-double-quotes\\",\\"description\\":\\"Attribute values must be in double quotes.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/attr-value-double-quotes\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"Tag must be paired, no start tag: [ </div> ]\\",\\"raw\\":\\"</div>\\",\\"evidence\\":\\" </div>\\",\\"line\\":25,\\"col\\":3,\\"rule\\":{\\"id\\":\\"tag-pair\\",\\"description\\":\\"Tag must be paired.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/tag-pair\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"Tag must be paired, no start tag: [ </bad> ]\\",\\"raw\\":\\"</bad>\\",\\"evidence\\":\\"</bad>\\",\\"line\\":26,\\"col\\":1,\\"rule\\":{\\"id\\":\\"tag-pair\\",\\"description\\":\\"Tag must be paired.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/tag-pair\\"}},{\\"type\\":\\"error\\",\\"message\\":\\"Tag must be paired, no start tag: [ </bad> ]\\",\\"raw\\":\\"</bad>\\",\\"evidence\\":\\"</bad>\\",\\"line\\":27,\\"col\\":1,\\"rule\\":{\\"id\\":\\"tag-pair\\",\\"description\\":\\"Tag must be paired.\\",\\"link\\":\\"https://github.com/thedaviddias/HTMLHint/wiki/tag-pair\\"}}],\\"time\\":99}]
5-
"
4+
Array [
5+
Object {
6+
"file": "<PROJECT_ROOT>/src/cli/formatters/__fixtures__/example.html",
7+
"messages": Array [
8+
Object {
9+
"col": 7,
10+
"evidence": " <div bad='' bad=''></div>",
11+
"line": 8,
12+
"message": "The value of attribute [ bad ] must be in double quotes.",
13+
"raw": " bad=''",
14+
"rule": Object {
15+
"description": "Attribute values must be in double quotes.",
16+
"id": "attr-value-double-quotes",
17+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/attr-value-double-quotes",
18+
},
19+
"type": "error",
20+
},
21+
Object {
22+
"col": 14,
23+
"evidence": " <div bad='' bad=''></div>",
24+
"line": 8,
25+
"message": "The value of attribute [ bad ] must be in double quotes.",
26+
"raw": " bad=''",
27+
"rule": Object {
28+
"description": "Attribute values must be in double quotes.",
29+
"id": "attr-value-double-quotes",
30+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/attr-value-double-quotes",
31+
},
32+
"type": "error",
33+
},
34+
Object {
35+
"col": 14,
36+
"evidence": " <div bad='' bad=''></div>",
37+
"line": 8,
38+
"message": "Duplicate of attribute name [ bad ] was found.",
39+
"raw": " bad=''",
40+
"rule": Object {
41+
"description": "Elements cannot have duplicate attributes.",
42+
"id": "attr-no-duplication",
43+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/attr-no-duplication",
44+
},
45+
"type": "error",
46+
},
47+
Object {
48+
"col": 7,
49+
"evidence": " <div bad='' bad=''></div>",
50+
"line": 9,
51+
"message": "The value of attribute [ bad ] must be in double quotes.",
52+
"raw": " bad=''",
53+
"rule": Object {
54+
"description": "Attribute values must be in double quotes.",
55+
"id": "attr-value-double-quotes",
56+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/attr-value-double-quotes",
57+
},
58+
"type": "error",
59+
},
60+
Object {
61+
"col": 14,
62+
"evidence": " <div bad='' bad=''></div>",
63+
"line": 9,
64+
"message": "The value of attribute [ bad ] must be in double quotes.",
65+
"raw": " bad=''",
66+
"rule": Object {
67+
"description": "Attribute values must be in double quotes.",
68+
"id": "attr-value-double-quotes",
69+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/attr-value-double-quotes",
70+
},
71+
"type": "error",
72+
},
73+
Object {
74+
"col": 14,
75+
"evidence": " <div bad='' bad=''></div>",
76+
"line": 9,
77+
"message": "Duplicate of attribute name [ bad ] was found.",
78+
"raw": " bad=''",
79+
"rule": Object {
80+
"description": "Elements cannot have duplicate attributes.",
81+
"id": "attr-no-duplication",
82+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/attr-no-duplication",
83+
},
84+
"type": "error",
85+
},
86+
Object {
87+
"col": 22,
88+
"evidence": " <input type=\\"text\\"></input>",
89+
"line": 10,
90+
"message": "Tag must be paired, no start tag: [ </input> ]",
91+
"raw": "</input>",
92+
"rule": Object {
93+
"description": "Tag must be paired.",
94+
"id": "tag-pair",
95+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/tag-pair",
96+
},
97+
"type": "error",
98+
},
99+
Object {
100+
"col": 3,
101+
"evidence": " <div class\\"foo\\">",
102+
"line": 11,
103+
"message": "Special characters must be escaped : [ < ].",
104+
"raw": "
105+
<div class\\"foo\\">
106+
107+
",
108+
"rule": Object {
109+
"description": "Special characters must be escaped.",
110+
"id": "spec-char-escape",
111+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/spec-char-escape",
112+
},
113+
"type": "error",
114+
},
115+
Object {
116+
"col": 18,
117+
"evidence": " <div class\\"foo\\">",
118+
"line": 11,
119+
"message": "Special characters must be escaped : [ > ].",
120+
"raw": "
121+
<div class\\"foo\\">
122+
123+
",
124+
"rule": Object {
125+
"description": "Special characters must be escaped.",
126+
"id": "spec-char-escape",
127+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/spec-char-escape",
128+
},
129+
"type": "error",
130+
},
131+
Object {
132+
"col": 11,
133+
"evidence": " </div>",
134+
"line": 13,
135+
"message": "Tag must be paired, no start tag: [ </div> ]",
136+
"raw": "</div>",
137+
"rule": Object {
138+
"description": "Tag must be paired.",
139+
"id": "tag-pair",
140+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/tag-pair",
141+
},
142+
"type": "error",
143+
},
144+
Object {
145+
"col": 9,
146+
"evidence": " </div>",
147+
"line": 14,
148+
"message": "Tag must be paired, no start tag: [ </div> ]",
149+
"raw": "</div>",
150+
"rule": Object {
151+
"description": "Tag must be paired.",
152+
"id": "tag-pair",
153+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/tag-pair",
154+
},
155+
"type": "error",
156+
},
157+
Object {
158+
"col": 7,
159+
"evidence": " </hello>",
160+
"line": 15,
161+
"message": "Tag must be paired, no start tag: [ </hello> ]",
162+
"raw": "</hello>",
163+
"rule": Object {
164+
"description": "Tag must be paired.",
165+
"id": "tag-pair",
166+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/tag-pair",
167+
},
168+
"type": "error",
169+
},
170+
Object {
171+
"col": 5,
172+
"evidence": " </test>",
173+
"line": 16,
174+
"message": "Tag must be paired, no start tag: [ </test> ]",
175+
"raw": "</test>",
176+
"rule": Object {
177+
"description": "Tag must be paired.",
178+
"id": "tag-pair",
179+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/tag-pair",
180+
},
181+
"type": "error",
182+
},
183+
Object {
184+
"col": 3,
185+
"evidence": " </div>",
186+
"line": 17,
187+
"message": "Tag must be paired, no start tag: [ </div> ]",
188+
"raw": "</div>",
189+
"rule": Object {
190+
"description": "Tag must be paired.",
191+
"id": "tag-pair",
192+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/tag-pair",
193+
},
194+
"type": "error",
195+
},
196+
Object {
197+
"col": 15,
198+
"evidence": " <div class='' what='' something=''></div>",
199+
"line": 21,
200+
"message": "The value of attribute [ class ] must be in double quotes.",
201+
"raw": " class=''",
202+
"rule": Object {
203+
"description": "Attribute values must be in double quotes.",
204+
"id": "attr-value-double-quotes",
205+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/attr-value-double-quotes",
206+
},
207+
"type": "error",
208+
},
209+
Object {
210+
"col": 24,
211+
"evidence": " <div class='' what='' something=''></div>",
212+
"line": 21,
213+
"message": "The value of attribute [ what ] must be in double quotes.",
214+
"raw": " what=''",
215+
"rule": Object {
216+
"description": "Attribute values must be in double quotes.",
217+
"id": "attr-value-double-quotes",
218+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/attr-value-double-quotes",
219+
},
220+
"type": "error",
221+
},
222+
Object {
223+
"col": 32,
224+
"evidence": " <div class='' what='' something=''></div>",
225+
"line": 21,
226+
"message": "The value of attribute [ something ] must be in double quotes.",
227+
"raw": " something=''",
228+
"rule": Object {
229+
"description": "Attribute values must be in double quotes.",
230+
"id": "attr-value-double-quotes",
231+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/attr-value-double-quotes",
232+
},
233+
"type": "error",
234+
},
235+
Object {
236+
"col": 3,
237+
"evidence": " </div>",
238+
"line": 25,
239+
"message": "Tag must be paired, no start tag: [ </div> ]",
240+
"raw": "</div>",
241+
"rule": Object {
242+
"description": "Tag must be paired.",
243+
"id": "tag-pair",
244+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/tag-pair",
245+
},
246+
"type": "error",
247+
},
248+
Object {
249+
"col": 1,
250+
"evidence": "</bad>",
251+
"line": 26,
252+
"message": "Tag must be paired, no start tag: [ </bad> ]",
253+
"raw": "</bad>",
254+
"rule": Object {
255+
"description": "Tag must be paired.",
256+
"id": "tag-pair",
257+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/tag-pair",
258+
},
259+
"type": "error",
260+
},
261+
Object {
262+
"col": 1,
263+
"evidence": "</bad>",
264+
"line": 27,
265+
"message": "Tag must be paired, no start tag: [ </bad> ]",
266+
"raw": "</bad>",
267+
"rule": Object {
268+
"description": "Tag must be paired.",
269+
"id": "tag-pair",
270+
"link": "https://github.com/thedaviddias/HTMLHint/wiki/tag-pair",
271+
},
272+
"type": "error",
273+
},
274+
],
275+
"time": 99,
276+
},
277+
]
6278
`;

src/cli/formatters/json.spec.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ describe('CLI', () => {
1919
expect(typeof error).toBe('object')
2020
expect(error.code).toBe(1)
2121

22-
expect(stdout.replace(/"time":\d+/, '"time":99')).toMatchSnapshot()
22+
expect(
23+
JSON.parse(stdout.replace(/"time":\d+/, '"time":99'))
24+
).toMatchSnapshot()
2325

2426
expect(stderr).toBe('')
2527
done()

0 commit comments

Comments
 (0)