feat(env): setSpecProperty/setSuiteProperty(key, value) to attach data to tests

Use setSpecProperty to attach key/value pairs to spec results that can be
picked up in specialized jasmine reporters.  Example use-cases
include:
  * Tagging specs with URLs or string-tokens referencing test-plan docs.
  * Recording performance information for blocks of JS.
Similarly setSuiteProperty attaches key/value pairs to suite results
This commit is contained in:
johnjbarton
2019-10-29 17:17:27 -07:00
parent f1eac6fb04
commit f90d9943fe
5 changed files with 124 additions and 3 deletions

View File

@@ -48,6 +48,7 @@ getJasmineRequireObj().Spec = function(j$) {
* @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
* @property {Object} properties - user-supplied key-value pairs.
*/
this.result = {
id: this.id,
@@ -57,7 +58,8 @@ getJasmineRequireObj().Spec = function(j$) {
passedExpectations: [],
deprecationWarnings: [],
pendingReason: '',
duration: null
duration: null,
properties: null
};
}
@@ -74,6 +76,11 @@ getJasmineRequireObj().Spec = function(j$) {
}
};
Spec.prototype.setSpecProperty = function(key, value) {
this.result.properties = this.result.properties || {};
this.result.properties[key] = value;
};
Spec.prototype.expect = function(actual) {
return this.expectationFactory(actual, this);
};