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:
@@ -227,7 +227,8 @@ describe('Spec', function() {
|
||||
passedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
pendingReason: '',
|
||||
duration: jasmine.any(Number)
|
||||
duration: jasmine.any(Number),
|
||||
properties: null
|
||||
},
|
||||
'things'
|
||||
);
|
||||
@@ -299,6 +300,23 @@ describe('Spec', function() {
|
||||
expect(duration).toBe(77000);
|
||||
});
|
||||
|
||||
it('should report properties set during the test', function() {
|
||||
var done = jasmine.createSpy('done callback'),
|
||||
spec = new jasmineUnderTest.Spec({
|
||||
queueableFn: { fn: jasmine.createSpy('spec body') },
|
||||
catchExceptions: function() {
|
||||
return false;
|
||||
},
|
||||
resultCallback: function() {},
|
||||
queueRunnerFactory: function(attrs) {
|
||||
attrs.onComplete();
|
||||
}
|
||||
});
|
||||
spec.setSpecProperty('a', 4);
|
||||
spec.execute(done);
|
||||
expect(spec.result.properties).toEqual({ a: 4 });
|
||||
});
|
||||
|
||||
it('#status returns passing by default', function() {
|
||||
var spec = new jasmineUnderTest.Spec({
|
||||
queueableFn: { fn: jasmine.createSpy('spec body') }
|
||||
|
||||
Reference in New Issue
Block a user