Skip to content

Commit b9a8a3f

Browse files
committed
fixup! copy reporter changes from jquery
1 parent 19055c8 commit b9a8a3f

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

tests/runner/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"browser": true
2525
},
2626
"globals": {
27-
"QUnit": false
27+
"QUnit": false,
28+
"Symbol": false
2829
},
2930
"parserOptions": {
3031
"ecmaVersion": 5,

tests/runner/listeners.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
( function() {
2-
32
"use strict";
43

54
// Get the report ID from the URL.
@@ -53,6 +52,14 @@
5352
return nu;
5453
}
5554
}
55+
56+
// Serialize Symbols as string representations so they are
57+
// sent over the wire after being stringified.
58+
if ( typeof value === "symbol" ) {
59+
var ctor = Symbol.keyFor( value ) !== undefined ? "Symbol.for" : "Symbol";
60+
return ctor + "(" + JSON.stringify( value.description ) + ")";
61+
}
62+
5663
return value;
5764
}
5865
return derez( object );
@@ -99,5 +106,4 @@
99106
};
100107
} );
101108
} );
102-
103109
} )();

tests/runner/reporter.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ import { getBrowserString } from "./lib/getBrowserString.js";
33
import { prettyMs } from "./lib/prettyMs.js";
44
import * as Diff from "diff";
55

6-
const rdquo = /"/g;
6+
function serializeForDiff( value ) {
77

8-
function quoteWrap( value ) {
8+
// Use naive serialization for everything except types with confusable values
99
if ( typeof value === "string" ) {
10-
return `"${ value.replace( rdquo, "\\\"" ) }"`;
10+
return JSON.stringify( value );
11+
}
12+
if ( typeof value === "bigint" ) {
13+
return `${ value }n`;
1114
}
1215
return `${ value }`;
1316
}
@@ -76,12 +79,12 @@ export function reportTest( test, reportId, { browser, headless } ) {
7679

7780
// Diff the characters of strings
7881
diff = Diff.diffChars( error.expected, error.actual );
79-
} else if ( error.expected != null && error.actual != null ) {
82+
} else {
8083

8184
// Diff everything else as words
8285
diff = Diff.diffWords(
83-
quoteWrap( error.expected ),
84-
quoteWrap( error.actual )
86+
serializeForDiff( error.expected ),
87+
serializeForDiff( error.actual )
8588
);
8689
}
8790

0 commit comments

Comments
 (0)