使用 Resharper 8 运行单元测试时,Qunit qunit-fixture div 被删除 [英] Qunit qunit-fixture div gets deleted running unit tests with Resharper 8

查看:74
本文介绍了使用 Resharper 8 运行单元测试时,Qunit qunit-fixture div 被删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,当我尝试在 div id="qunit-fixture" 中添加或设置 HTML 代码时,在 ReSharper 8 下运行 Qunit 进行测试时.div id="qunit-fixture" 被删除了一些原因.我需要测试文档就绪函数中指定的事件,但如果我无法在 div id="qunit-fixture" 中添加元素,则无法测试.有什么解决办法吗?

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?

推荐答案

它不会被删除.Resharper QUnit 测试运行器根本没有它!

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

您可以在浏览器打开时亲自查看,并检查 HTML 的查看源代码".

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

为了克服这个问题,您可能需要按如下方式设置 QUnit 测试模块:

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

    ...
 }

这篇关于使用 Resharper 8 运行单元测试时,Qunit qunit-fixture div 被删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆