Dynamically update spec description #629

Closed
robrichard opened this Issue Jul 18, 2014 · 2 comments

Comments

Projects
None yet
2 participants

I'm using jasmine 2.0 to do integration tests with a REST API. I'd like to add some information that is created dynamically to the output report to aid debugging when tests fail. Is it possible to do something like this?

For example:

describe('My Test', function () {
    var model = new MyModel();
    beforeEach(function (done) {
        // Creates a new model in the service
        model.save().done(done); 
    });
    it('should have properties', function () {
        // Update spec name to have dynamically created ID
        this.name = this.name + ' (ID: ' + model.get('id') + ')'; 
        expect(model.get('prop')).toBe('val');
    });
});

Output (1234 as the model ID from the service)

My Test
- should have properties (ID: 1234)

robrichard changed the title from Dynamically update describe description to Dynamically update spec description Jul 18, 2014

It looks like this used to be possible with jasmine.currentEnv_.currentSpec.description. Is there a way to do the same in jasmine 2.0?

http://blog.jphpsf.com/2012/08/30/drying-up-your-javascript-jasmine-tests

Owner

slackersoft commented Sep 3, 2014

This wasn't intentionally exposed in jasmine 1.3.x, and in the rework for jasmine 2.0, we've closed over a number of things that used to be public but really shouldn't have been. I don't think we have any plans to enable users to mutate spec or suite descriptions, as it could make it hard to then find the spec/suite in your code.

Closing this.

slackersoft closed this Sep 3, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment