lundi 19 mars 2018

Having multiple qunit-fixture in QUnit test?

Is it possible to have multiple but independent fixtures in qunit-fixture?

I need to use different fixtures for different examples, but only one of them can be in the DOM at the same time.

For example:

<div id="qunit-fixture"></div>
    <div id="for-test-1" class="test-fixture"></div>
    <div id="for-test-2" class""test-fixture></div>
</div>

Right now I'm forced to use display:none; for all of them by default and then use display:block for the one I'm testing. Something I accomplish this way:

QUnit.test("Testing test1", function(assert) {
    $('.test-fixture').hide();
    $('#for-test-1').show();
    //start my test here.
});

QUnit.test("Testing test2", function(assert) {
    $('.test-fixture').hide();
    $('#for-test-2').show();
    //start my test here.
});

Is there any better way of dealing with this scenario ?

Aucun commentaire:

Enregistrer un commentaire