Require spec/suite property keys to be strings, not just anything that's cloneable and serializable

This matches the jsdoc.
This commit is contained in:
Steve Gravrock
2025-10-18 17:22:48 -07:00
parent d66d0d9d2e
commit 4201fd848f
5 changed files with 32 additions and 22 deletions

View File

@@ -409,12 +409,12 @@ describe('Suite', function() {
});
describe('#setSuiteProperty', function() {
it('throws if the key is not structured-cloneable', function() {
it('throws if the key is not a string', function() {
const suite = new privateUnderTest.Suite({});
expect(function() {
suite.setSuiteProperty(new Promise(() => {}), '');
}).toThrowError("Key can't be cloned");
suite.setSuiteProperty({}, '');
}).toThrowError('Key must be a string');
});
it('throws if the value is not structured-cloneable', function() {
@@ -424,6 +424,16 @@ describe('Suite', function() {
suite.setSuiteProperty('k', new Promise(() => {}));
}).toThrowError("Value can't be cloned");
});
it('throws if the value is not JSON-serializable', function() {
const suite = new privateUnderTest.Suite({});
expect(function() {
const v = {};
v.self = v;
suite.setSuiteProperty('k', v);
}).toThrowError("Value can't be cloned");
});
});
describe('#startedEvent', function() {