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

懵懂的女人 提交于 2019-12-10 17:45:58

问题


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?


回答1:


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' />");

    ...
 }


来源:https://stackoverflow.com/questions/19178572/qunit-qunit-fixture-div-gets-deleted-running-unit-tests-with-resharper-8

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!