Skip to content

Commit 092783f

Browse files
committed
Don't report expected and actual properties of expectations results
These have never been reliable due to serializability issues, appear to have never been used, and are deprecated in jasmine-core. Removing them entirely fixes an un-catchable error when Selenium tries to serialize detatched DOM nodes, and generally ends the game of serialization error whack-a-mole. Fixes #67.
1 parent eb1138b commit 092783f

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/runner.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ function getBatch(driver) {
88
'if (results[i][1].passedExpectations) {\n' +
99
'expectations = expectations.concat(results[i][1].passedExpectations);\n' +
1010
'}\n' +
11-
'for (var j = 0; j < expectations.length; j++) {\n' +
12-
'var expectation = expectations[j];\n' +
13-
"try { JSON.stringify(expectation.expected); } catch (e) { expectation.expected = '<circular expected>'; }\n" +
14-
"try { JSON.stringify(expectation.actual); } catch (e) { expectation.actual = '<circular actual>'; }\n" +
15-
'}\n' +
1611
'}\n' +
1712
'return results;'
1813
);

lib/support/batchReporter.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,31 @@ function BatchReporter() {
2121
};
2222

2323
this.jasmineDone = function(info) {
24+
deleteExpectedAndActual(info);
2425
events.push(['jasmineDone', info]);
2526
};
2627

2728
this.suiteDone = function(info) {
29+
deleteExpectedAndActual(info);
2830
events.push(['suiteDone', info]);
2931
};
3032

3133
this.specDone = function(info) {
34+
deleteExpectedAndActual(info);
3235
events.push(['specDone', info]);
3336
};
37+
38+
function deleteExpectedAndActual(info) {
39+
for (const e of info.failedExpectations) {
40+
// Delete expected and actual. Not all JS objects are serializable, we
41+
// don't have a reliable way to determine what Selenium can and can't
42+
// serialize, not everything that's serializable survives the process
43+
// intact, and there are no known reporters that use the expected or
44+
// actual properties of expectation results.
45+
delete e.expected;
46+
delete e.actual;
47+
}
48+
}
3449
}
3550

3651
window.batchReporter = new BatchReporter();

0 commit comments

Comments
 (0)