David Max
David Max

Reputation: 31

Qunit qunit-fixture div gets deleted running unit tests with Resharper 8

I have an issue that when I try to append or set up HTML code in the div id="qunit-fixture" when testing with Qunit running under ReSharper 8. The div id="qunit-fixture" is deleted for some reason. I need to test events specified in the document ready function but can not do so if I can not add the elements in the div id="qunit-fixture". Are there any solutions for this?

Upvotes: 3

Views: 456

Answers (1)

Arcturus
Arcturus

Reputation: 27055

It does not get deleted. It is simply not there with the Resharper QUnit test runner!

You can see for yourself when the browser opens, and check the "view source" of the HTML.

To overcome this problem, you might want to setup your QUnit test module as follows:

module("Tests for DOM manipulation", {
    setup: function() {
        $("body").append("<div id='qunit-fixture' />");
    },
    teardown: function () {
        $("#qunit-fixture").remove();
    }
});

test("Some atomic jQuery test", function () {
    $("#qunit-fixture").append("<span id='myId' />");

    ...
 }

Upvotes: 2

Related Questions