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

@@ -27,6 +27,7 @@ getJasmineRequireObj().Suite = function(j$) {
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred on this suite.
* @property {String} status - Once the suite has completed, this string represents the pass/fail status of this suite.
* @property {number} duration - The time in ms for Suite execution, including any before/afterAll, before/afterEach.
* @property {Object} properties - user-supplied key-value pairs.
*/
this.result = {
id: this.id,
@@ -34,10 +35,16 @@ getJasmineRequireObj().Suite = function(j$) {
fullName: this.getFullName(),
failedExpectations: [],
deprecationWarnings: [],
duration: null
duration: null,
properties: null
};
}
Suite.prototype.setSuiteProperty = function(key, value) {
this.result.properties = this.result.properties || {};
this.result.properties[key] = value;
};
Suite.prototype.expect = function(actual) {
return this.expectationFactory(actual, this);
};