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