Also require setSpecProperty/setSuiteProperty args to be JSON serializable
This commit is contained in:
@@ -74,8 +74,8 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
// Key and value will eventually be cloned during reporting. The error
|
||||
// thrown at that point if they aren't cloneable isn't very helpful.
|
||||
// Throw a better one now.
|
||||
j$.private.util.assertStructuredCloneable(key, 'Key');
|
||||
j$.private.util.assertStructuredCloneable(value, 'Value');
|
||||
j$.private.util.assertReporterCloneable(key, 'Key');
|
||||
j$.private.util.assertReporterCloneable(value, 'Value');
|
||||
this.result.properties = this.result.properties || {};
|
||||
this.result.properties[key] = value;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
// Key and value will eventually be cloned during reporting. The error
|
||||
// thrown at that point if they aren't cloneable isn't very helpful.
|
||||
// Throw a better one now.
|
||||
j$.private.util.assertStructuredCloneable(key, 'Key');
|
||||
j$.private.util.assertStructuredCloneable(value, 'Value');
|
||||
j$.private.util.assertReporterCloneable(key, 'Key');
|
||||
j$.private.util.assertReporterCloneable(value, 'Value');
|
||||
this.result.properties = this.result.properties || {};
|
||||
this.result.properties[key] = value;
|
||||
}
|
||||
|
||||
@@ -80,9 +80,12 @@ getJasmineRequireObj().util = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
util.assertStructuredCloneable = function(v, msgPrefix) {
|
||||
util.assertReporterCloneable = function(v, msgPrefix) {
|
||||
try {
|
||||
structuredClone(v);
|
||||
// Reporter events are cloned internally via structuredClone, and it's
|
||||
// common for reporters (including jasmine-browser-runner's) to JSON
|
||||
// serialize them.
|
||||
JSON.stringify(structuredClone(v));
|
||||
} catch (e) {
|
||||
throw new Error(`${msgPrefix} can't be cloned`, { cause: e });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user