lundi 28 mars 2016

JavaScript Unit Testing with Jasmine: Invocation with different value than in beforeEach

I am writing a unit test using Jasmine for a JavaScript module. In the beforeEach method I create a new instance of my module:

beforeEach(function () {
    myModule = new MyModule();
});

As you can see, I don't pass anything to the constructor. Unfortunately, I wan't to test how the module behaves when something is passed to check the behaviour of default values. Is there a recommended way to do something like this in Jasmine, like "skipping" beforeEach?

Currently I am just redefining myModule inside the expectation:

it('should do something', function () {
  myModule = new MyModule('some', 'values', 'here');
});

., also from a performance point of view.

Aucun commentaire:

Enregistrer un commentaire