feat(getSpecProperty) get a user-defined property

This commit is contained in:
kbon
2025-08-25 23:00:06 -04:00
parent db65c3b131
commit f822ffea21
5 changed files with 102 additions and 2 deletions

View File

@@ -779,6 +779,26 @@ getJasmineRequireObj().Env = function(j$) {
return suiteBuilder.fit(description, fn, timeout, filename).metadata;
};
/**
* Get a user-defined property as part of the properties field of {@link SpecResult}
* @name Env#getSpecProperty
* @since 5.10.0
* @function
* @param {String} key The name of the property
* @returns {*} The value of the property
*/
this.getSpecProperty = function(key) {
if (
!runner.currentRunable() ||
runner.currentRunable() == runner.currentSuite()
) {
throw new Error(
"'getSpecProperty' was used when there was no current spec"
);
}
return runner.currentRunable().getSpecProperty(key);
};
/**
* Sets a user-defined property that will be provided to reporters as part of the properties field of {@link SpecResult}
* @name Env#setSpecProperty