lundi 8 juin 2015

QUnit: How to pass a global variable reference?

I have a qunit module that doesn't allow a created object's method to see a global variable. The simplified version:

qunit.module("testcases", {
    setup: function () {
        var globalVar = "something";
    }
});
test("test1", function () {
   obj = new MyObj({});
   obj.execute(); // uses globalVar but doesn't see it 
});

How can I get the obj instance to recognize the globalVar?

I tried defining globalVar within test1 as well, but no luck. I don't want to put the globalVar on the obj instance, since it's execute function doesn't check on itself for the global

Aucun commentaire:

Enregistrer un commentaire