Skip to content

Commit 5869d76

Browse files
authored
test(stryker): Replace line numbers by error index (#201)
* test(stryker): Replace line numbers by error index so the snapshots match even when stryker mutates the files. * cleanup: Remove commented `console.error` statements since stryker tends to put code in front of them. (Latest version of test/error/reported.js` deals with those anyways, but I don't see a reason why we should ship those lines downstream.) * refactor: Less specific to lib/sax.js
1 parent a681852 commit 5869d76

5 files changed

Lines changed: 160 additions & 57 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33

44
/node_modules
55
/reports
6+
/test/error/reported.json

‎lib/sax.js‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,13 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
120120
if(end<0){
121121

122122
tagName = source.substring(tagStart+2).replace(/[\s<].*/,'');
123-
//console.error('#@@@@@@'+tagName)
124123
errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName);
125124
end = tagStart+1+tagName.length;
126125
}else if(tagName.match(/\s</)){
127126
tagName = tagName.replace(/[\s<].*/,'');
128127
errorHandler.error("end tag name: "+tagName+' maybe not complete');
129128
end = tagStart+1+tagName.length;
130129
}
131-
//console.error(parseStack.length,parseStack)
132-
//console.error(config);
133130
var localNSMap = config.localNSMap;
134131
var endMatch = config.tagName == tagName;
135132
var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()
@@ -181,7 +178,6 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
181178
position(a.offset);
182179
a.locator = copyLocator(locator,{});
183180
}
184-
//}catch(e){console.error('@@@@@'+e)}
185181
domBuilder.locator = locator2
186182
if(appendElement(el,domBuilder,currentNSMap)){
187183
parseStack.push(el)

‎test/error/__snapshots__/reported-levels.test.js.snap‎

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Array [
1010
exports[`SYNTAX_AttributeEqualMissingValue with mimeType text/html should not catch Error thrown in errorHandler.error 1`] = `
1111
Array [
1212
"[xmldom error] element parse error: Error: attribute value missed!!||@#[line:1,col:1]
13-
at parse (lib/sax.js:208)",
13+
at parse (lib/sax.js:#5)",
1414
]
1515
`;
1616

@@ -24,7 +24,7 @@ Array [
2424
exports[`SYNTAX_AttributeEqualMissingValue with mimeType text/xml should not catch Error thrown in errorHandler.error 1`] = `
2525
Array [
2626
"[xmldom error] element parse error: Error: attribute value missed!!||@#[line:1,col:1]
27-
at parse (lib/sax.js:208)",
27+
at parse (lib/sax.js:#5)",
2828
]
2929
`;
3030

@@ -38,7 +38,7 @@ Array [
3838
exports[`SYNTAX_AttributeMissingEndingQuote with mimeType text/html should not catch Error thrown in errorHandler.error 1`] = `
3939
Array [
4040
"[xmldom error] element parse error: Error: attribute value no end '\\"' match||@#[line:1,col:1]
41-
at parse (lib/sax.js:208)",
41+
at parse (lib/sax.js:#5)",
4242
]
4343
`;
4444

@@ -52,7 +52,7 @@ Array [
5252
exports[`SYNTAX_AttributeMissingEndingQuote with mimeType text/xml should not catch Error thrown in errorHandler.error 1`] = `
5353
Array [
5454
"[xmldom error] element parse error: Error: attribute value no end '\\"' match||@#[line:1,col:1]
55-
at parse (lib/sax.js:208)",
55+
at parse (lib/sax.js:#5)",
5656
]
5757
`;
5858

@@ -66,7 +66,7 @@ Array [
6666
exports[`SYNTAX_ElementClosingNotConnected with mimeType text/html should not catch Error thrown in errorHandler.error 1`] = `
6767
Array [
6868
"[xmldom error] element parse error: Error: elements closed character '/' and '>' must be connected to||@#[line:1,col:6]
69-
at parse (lib/sax.js:208)",
69+
at parse (lib/sax.js:#5)",
7070
]
7171
`;
7272

@@ -80,7 +80,7 @@ Array [
8080
exports[`SYNTAX_ElementClosingNotConnected with mimeType text/xml should not catch Error thrown in errorHandler.error 1`] = `
8181
Array [
8282
"[xmldom error] element parse error: Error: elements closed character '/' and '>' must be connected to||@#[line:1,col:6]
83-
at parse (lib/sax.js:208)",
83+
at parse (lib/sax.js:#5)",
8484
]
8585
`;
8686

@@ -94,9 +94,9 @@ Array [
9494
exports[`SYNTAX_EndTagMaybeNotComplete with mimeType text/html should not catch Error thrown in errorHandler.error 1`] = `
9595
Array [
9696
"[xmldom error] end tag name: inner maybe not complete||@#[line:1,col:6]
97-
at parse (lib/sax.js:128)",
97+
at parse (lib/sax.js:#2)",
9898
"[xmldom error] element parse error: Error: [xmldom error] end tag name: inner maybe not complete||@#[line:1,col:6]||@#[line:1,col:6]
99-
at parse (lib/sax.js:208)",
99+
at parse (lib/sax.js:#5)",
100100
]
101101
`;
102102

@@ -110,9 +110,9 @@ Array [
110110
exports[`SYNTAX_EndTagMaybeNotComplete with mimeType text/xml should not catch Error thrown in errorHandler.error 1`] = `
111111
Array [
112112
"[xmldom error] end tag name: inner maybe not complete||@#[line:1,col:6]
113-
at parse (lib/sax.js:128)",
113+
at parse (lib/sax.js:#2)",
114114
"[xmldom error] element parse error: Error: [xmldom error] end tag name: inner maybe not complete||@#[line:1,col:6]||@#[line:1,col:6]
115-
at parse (lib/sax.js:208)",
115+
at parse (lib/sax.js:#5)",
116116
]
117117
`;
118118

@@ -126,9 +126,9 @@ Array [
126126
exports[`SYNTAX_EndTagNotComplete with mimeType text/html should not catch Error thrown in errorHandler.error 1`] = `
127127
Array [
128128
"[xmldom error] end tag name: xml is not complete:xml||@#[line:1,col:1]
129-
at parse (lib/sax.js:124)",
129+
at parse (lib/sax.js:#1)",
130130
"[xmldom error] element parse error: Error: [xmldom error] end tag name: xml is not complete:xml||@#[line:1,col:1]||@#[line:1,col:1]
131-
at parse (lib/sax.js:208)",
131+
at parse (lib/sax.js:#5)",
132132
]
133133
`;
134134

@@ -142,9 +142,9 @@ Array [
142142
exports[`SYNTAX_EndTagNotComplete with mimeType text/xml should not catch Error thrown in errorHandler.error 1`] = `
143143
Array [
144144
"[xmldom error] end tag name: xml is not complete:xml||@#[line:1,col:1]
145-
at parse (lib/sax.js:124)",
145+
at parse (lib/sax.js:#1)",
146146
"[xmldom error] element parse error: Error: [xmldom error] end tag name: xml is not complete:xml||@#[line:1,col:1]||@#[line:1,col:1]
147-
at parse (lib/sax.js:208)",
147+
at parse (lib/sax.js:#5)",
148148
]
149149
`;
150150

@@ -158,7 +158,7 @@ Array [
158158
exports[`SYNTAX_InvalidAttributeName with mimeType text/html should not catch Error thrown in errorHandler.error 1`] = `
159159
Array [
160160
"[xmldom error] element parse error: Error: invalid attribute:123||@#[line:1,col:1]
161-
at parse (lib/sax.js:208)",
161+
at parse (lib/sax.js:#5)",
162162
]
163163
`;
164164

@@ -172,7 +172,7 @@ Array [
172172
exports[`SYNTAX_InvalidAttributeName with mimeType text/xml should not catch Error thrown in errorHandler.error 1`] = `
173173
Array [
174174
"[xmldom error] element parse error: Error: invalid attribute:123||@#[line:1,col:1]
175-
at parse (lib/sax.js:208)",
175+
at parse (lib/sax.js:#5)",
176176
]
177177
`;
178178

@@ -186,7 +186,7 @@ Array [
186186
exports[`SYNTAX_InvalidTagName with mimeType text/html should not catch Error thrown in errorHandler.error 1`] = `
187187
Array [
188188
"[xmldom error] element parse error: Error: invalid tagName:123||@#[line:1,col:1]
189-
at parse (lib/sax.js:208)",
189+
at parse (lib/sax.js:#5)",
190190
]
191191
`;
192192

@@ -200,7 +200,7 @@ Array [
200200
exports[`SYNTAX_InvalidTagName with mimeType text/xml should not catch Error thrown in errorHandler.error 1`] = `
201201
Array [
202202
"[xmldom error] element parse error: Error: invalid tagName:123||@#[line:1,col:1]
203-
at parse (lib/sax.js:208)",
203+
at parse (lib/sax.js:#5)",
204204
]
205205
`;
206206

@@ -214,9 +214,9 @@ Array [
214214
exports[`SYNTAX_UnclosedComment with mimeType text/html should not catch Error thrown in errorHandler.error 1`] = `
215215
Array [
216216
"[xmldom error] Unclosed comment||@#[line:1,col:1]
217-
at parseDCC (lib/sax.js:538)",
217+
at parseDCC (lib/sax.js:#21)",
218218
"[xmldom error] element parse error: Error: [xmldom error] Unclosed comment||@#[line:1,col:1]||@#[line:1,col:1]
219-
at parse (lib/sax.js:208)",
219+
at parse (lib/sax.js:#5)",
220220
]
221221
`;
222222

@@ -230,9 +230,9 @@ Array [
230230
exports[`SYNTAX_UnclosedComment with mimeType text/xml should not catch Error thrown in errorHandler.error 1`] = `
231231
Array [
232232
"[xmldom error] Unclosed comment||@#[line:1,col:1]
233-
at parseDCC (lib/sax.js:538)",
233+
at parseDCC (lib/sax.js:#21)",
234234
"[xmldom error] element parse error: Error: [xmldom error] Unclosed comment||@#[line:1,col:1]||@#[line:1,col:1]
235-
at parse (lib/sax.js:208)",
235+
at parse (lib/sax.js:#5)",
236236
]
237237
`;
238238

@@ -246,9 +246,9 @@ Array [
246246
exports[`SYNTAX_UnexpectedEndOfInput with mimeType text/html should not catch Error thrown in errorHandler.error 1`] = `
247247
Array [
248248
"[xmldom error] unexpected end of input||@#[line:1,col:1]
249-
at parseElementStartPart (lib/sax.js:308)",
249+
at parseElementStartPart (lib/sax.js:#13)",
250250
"[xmldom error] element parse error: Error: [xmldom error] unexpected end of input||@#[line:1,col:1]||@#[line:1,col:1]
251-
at parse (lib/sax.js:208)",
251+
at parse (lib/sax.js:#5)",
252252
]
253253
`;
254254

@@ -262,9 +262,9 @@ Array [
262262
exports[`SYNTAX_UnexpectedEndOfInput with mimeType text/xml should not catch Error thrown in errorHandler.error 1`] = `
263263
Array [
264264
"[xmldom error] unexpected end of input||@#[line:1,col:1]
265-
at parseElementStartPart (lib/sax.js:308)",
265+
at parseElementStartPart (lib/sax.js:#13)",
266266
"[xmldom error] element parse error: Error: [xmldom error] unexpected end of input||@#[line:1,col:1]||@#[line:1,col:1]
267-
at parse (lib/sax.js:208)",
267+
at parse (lib/sax.js:#5)",
268268
]
269269
`;
270270

@@ -278,7 +278,7 @@ Array [
278278
exports[`WF_AttributeMissingQuote with mimeType text/html should escalate Error thrown in errorHandler.warning to errorHandler.error 1`] = `
279279
Array [
280280
"[xmldom warning] attribute \\"value\\" missed quot(\\")!||@#[line:1,col:1]
281-
at parseElementStartPart (lib/sax.js:333)",
281+
at parseElementStartPart (lib/sax.js:#14)",
282282
]
283283
`;
284284

@@ -292,7 +292,7 @@ Array [
292292
exports[`WF_AttributeMissingQuote with mimeType text/xml should escalate Error thrown in errorHandler.warning to errorHandler.error 1`] = `
293293
Array [
294294
"[xmldom warning] attribute \\"value\\" missed quot(\\")!||@#[line:1,col:1]
295-
at parseElementStartPart (lib/sax.js:333)",
295+
at parseElementStartPart (lib/sax.js:#14)",
296296
]
297297
`;
298298

@@ -306,7 +306,7 @@ Array [
306306
exports[`WF_AttributeMissingQuote2 with mimeType text/html should escalate Error thrown in errorHandler.warning to errorHandler.error 1`] = `
307307
Array [
308308
"[xmldom warning] attribute \\"&\\" missed quot(\\")!!||@#[line:1,col:1]
309-
at parseElementStartPart (lib/sax.js:363)",
309+
at parseElementStartPart (lib/sax.js:#17)",
310310
]
311311
`;
312312

@@ -320,7 +320,7 @@ Array [
320320
exports[`WF_AttributeMissingQuote2 with mimeType text/xml should escalate Error thrown in errorHandler.warning to errorHandler.error 1`] = `
321321
Array [
322322
"[xmldom warning] attribute \\"&\\" missed quot(\\")!!||@#[line:1,col:1]
323-
at parseElementStartPart (lib/sax.js:363)",
323+
at parseElementStartPart (lib/sax.js:#17)",
324324
]
325325
`;
326326

@@ -334,7 +334,7 @@ Array [
334334
exports[`WF_AttributeMissingStartingQuote with mimeType text/html should escalate Error thrown in errorHandler.warning to errorHandler.error 1`] = `
335335
Array [
336336
"[xmldom warning] attribute \\"attr\\" missed start quot(\\")!!||@#[line:1,col:1]
337-
at parseElementStartPart (lib/sax.js:281)",
337+
at parseElementStartPart (lib/sax.js:#10)",
338338
]
339339
`;
340340

@@ -348,7 +348,7 @@ Array [
348348
exports[`WF_AttributeMissingStartingQuote with mimeType text/xml should escalate Error thrown in errorHandler.warning to errorHandler.error 1`] = `
349349
Array [
350350
"[xmldom warning] attribute \\"attr\\" missed start quot(\\")!!||@#[line:1,col:1]
351-
at parseElementStartPart (lib/sax.js:281)",
351+
at parseElementStartPart (lib/sax.js:#10)",
352352
]
353353
`;
354354

@@ -362,7 +362,7 @@ Array [
362362
exports[`WF_AttributeMissingValue with mimeType text/html should escalate Error thrown in errorHandler.warning to errorHandler.error 1`] = `
363363
Array [
364364
"[xmldom warning] attribute \\"attr\\" missed value!! \\"attr\\" instead!!||@#[line:1,col:1]
365-
at parseElementStartPart (lib/sax.js:337)",
365+
at parseElementStartPart (lib/sax.js:#15)",
366366
]
367367
`;
368368

@@ -376,7 +376,7 @@ Array [
376376
exports[`WF_AttributeMissingValue with mimeType text/xml should escalate Error thrown in errorHandler.warning to errorHandler.error 1`] = `
377377
Array [
378378
"[xmldom warning] attribute \\"attr\\" missed value!! \\"attr\\" instead!!||@#[line:1,col:1]
379-
at parseElementStartPart (lib/sax.js:337)",
379+
at parseElementStartPart (lib/sax.js:#15)",
380380
]
381381
`;
382382

@@ -392,7 +392,7 @@ Array [
392392
exports[`WF_AttributeMissingValue2 with mimeType text/html should escalate Error thrown in errorHandler.warning to errorHandler.error 1`] = `
393393
Array [
394394
"[xmldom warning] attribute \\"attr\\" missed value!! \\"attr\\" instead2!!||@#[line:1,col:1]
395-
at parseElementStartPart (lib/sax.js:385)",
395+
at parseElementStartPart (lib/sax.js:#18)",
396396
]
397397
`;
398398

@@ -408,7 +408,7 @@ Array [
408408
exports[`WF_AttributeMissingValue2 with mimeType text/xml should escalate Error thrown in errorHandler.warning to errorHandler.error 1`] = `
409409
Array [
410410
"[xmldom warning] attribute \\"attr\\" missed value!! \\"attr\\" instead2!!||@#[line:1,col:1]
411-
at parseElementStartPart (lib/sax.js:385)",
411+
at parseElementStartPart (lib/sax.js:#18)",
412412
]
413413
`;
414414

@@ -422,7 +422,7 @@ Array [
422422
exports[`WF_AttributeValueMustAfterEqual with mimeType text/html should escalate Error thrown in errorHandler.warning to errorHandler.error 1`] = `
423423
Array [
424424
"[xmldom warning] attribute value must after \\"=\\"||@#[line:1,col:1]
425-
at parseElementStartPart (lib/sax.js:263)",
425+
at parseElementStartPart (lib/sax.js:#8)",
426426
]
427427
`;
428428

@@ -436,7 +436,7 @@ Array [
436436
exports[`WF_AttributeValueMustAfterEqual with mimeType text/xml should escalate Error thrown in errorHandler.warning to errorHandler.error 1`] = `
437437
Array [
438438
"[xmldom warning] attribute value must after \\"=\\"||@#[line:1,col:1]
439-
at parseElementStartPart (lib/sax.js:263)",
439+
at parseElementStartPart (lib/sax.js:#8)",
440440
]
441441
`;
442442

@@ -464,9 +464,9 @@ Array [
464464
exports[`WF_EntityDeclared with mimeType text/html should not catch Error thrown in errorHandler.error 1`] = `
465465
Array [
466466
"[xmldom error] entity not found:&e;||@#[line:1,col:1]
467-
at replace (lib/sax.js:71)",
467+
at replace (lib/sax.js:#0)",
468468
"[xmldom error] element parse error: Error: [xmldom error] entity not found:&e;||@#[line:1,col:1]||@#[line:1,col:1]
469-
at parse (lib/sax.js:208)",
469+
at parse (lib/sax.js:#5)",
470470
]
471471
`;
472472

@@ -480,9 +480,9 @@ Array [
480480
exports[`WF_EntityDeclared with mimeType text/xml should not catch Error thrown in errorHandler.error 1`] = `
481481
Array [
482482
"[xmldom error] entity not found:&e;||@#[line:1,col:1]
483-
at replace (lib/sax.js:71)",
483+
at replace (lib/sax.js:#0)",
484484
"[xmldom error] element parse error: Error: [xmldom error] entity not found:&e;||@#[line:1,col:1]||@#[line:1,col:1]
485-
at parse (lib/sax.js:208)",
485+
at parse (lib/sax.js:#5)",
486486
]
487487
`;
488488

@@ -496,6 +496,6 @@ Array [
496496
exports[`WF_UnclosedXmlAttribute with mimeType text/xml should escalate Error thrown in errorHandler.warning to errorHandler.error 1`] = `
497497
Array [
498498
"[xmldom warning] unclosed xml attribute||@#[line:1,col:1]
499-
at parse (lib/sax.js:173)",
499+
at parse (lib/sax.js:#4)",
500500
]
501501
`;

0 commit comments

Comments
 (0)