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

@@ -1124,6 +1124,24 @@ getJasmineRequireObj().Env = function(j$) {
return spec;
};
this.setSpecProperty = function(key, value) {
if (!currentRunnable() || currentRunnable() == currentSuite()) {
throw new Error(
"'setSpecProperty' was used when there was no current spec"
);
}
currentRunnable().setSpecProperty(key, value);
};
this.setSuiteProperty = function(key, value) {
if (!currentSuite()) {
throw new Error(
"'setSuiteProperty' was used when there was no current suite"
);
}
currentSuite().setSuiteProperty(key, value);
};
this.expect = function(actual) {
if (!currentRunnable()) {
throw new Error(