Javascript 如何将Blanket.js与使用jQuery.noConflict运行的QUnit测试一起使用(true)

Javascript 如何将Blanket.js与使用jQuery.noConflict运行的QUnit测试一起使用(true),javascript,jquery,testing,code-coverage,blanket.js,Javascript,Jquery,Testing,Code Coverage,Blanket.js,我正在使用quonit测试我正在编写的jQuery插件,并希望使用blanket生成覆盖信息 我的测试看起来像: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>My Awesome Test Suite</title> <!-- Load local jQuery. This can be overridden with a ?jqu

我正在使用
quonit
测试我正在编写的
jQuery插件
,并希望使用
blanket
生成覆盖信息

我的测试看起来像:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>My Awesome Test Suite</title>
  <!-- Load local jQuery. This can be overridden with a ?jquery=___ param. -->
  <script src="../libs/jquery-loader.js"></script>

  <!-- Load local QUnit. -->
  <link rel="stylesheet" href="../libs/qunit/qunit.css" media="screen">
  <script src="../libs/qunit/qunit.js"></script>

  <!-- Code Coverage with Blanket -->
  <script src="../node_modules/blanket/dist/qunit/blanket.min.js"></script>

  <!-- Load local lib and tests. -->
  <script src="../build/thingToTest.js" data-cover></script>
  <script src="../build/test/thingToTest_test.js"></script>
  <!-- Removing access to jQuery and $. But it'll still be available as _$, if
       you REALLY want to mess around with jQuery in the console. REMEMBER WE
       ARE TESTING A PLUGIN HERE, THIS HELPS ENSURE BEST PRACTICES. REALLY. -->
  <script>window._$ = jQuery.noConflict(true);</script>
</head>
<body>
  <div id="qunit">
    <h1 id="qunit-header">QUnit Tests</h1>
    <h2 id="qunit-banner"></h2>
    <div id="qunit-testrunner-toolbar"></div>
    <h2 id="qunit-userAgent"></h2>
  </div>
  <ol id="qunit-tests"></ol>
  <div id="qunit-fixture">
    <div class="thingToTest-container">
    </div>
  </div>
</body>
</html>
如果我把这行注释掉

<script>window._$ = jQuery.noConflict(true);</script>
window.\u$=jQuery.noConflict(true);
然后,
毯子
就可以了

在简单的情况下,这是可以接受的,但在更复杂的情况下,我确实希望以
noConflict
模式加载jQuery,以确保测试的纯度


有没有办法做到这一点?

我也有同样的问题。我在HTML中为qUnit测试向jQuery脚本标记添加了数据覆盖,它成功了,我认为工具需要看到它

编辑

我还注意到我的qUnit html中有这一行

<!-- Removing access to jQuery and $. But it'll still be available as _$, if
  you REALLY want to mess around with jQuery in the console. REMEMBER WE
  ARE TESTING A PLUGIN HERE, THIS HELPS ENSURE BEST PRACTICES. REALLY. -->
<script>window._$ = jQuery.noConflict(true);</script>

window.\u$=jQuery.noConflict(true);

通过删除该块,它不再需要jQuery标记上的数据封面。

谢谢。我想知道哪个更好,在整个jQuery中添加覆盖率(不可能给出合理的覆盖率统计),还是不在
noConflict
模式下运行jQuery。我怀疑是后者,但我正在寻找一种解决方案,使我能够利用使用
noConflict
<!-- Removing access to jQuery and $. But it'll still be available as _$, if
  you REALLY want to mess around with jQuery in the console. REMEMBER WE
  ARE TESTING A PLUGIN HERE, THIS HELPS ENSURE BEST PRACTICES. REALLY. -->
<script>window._$ = jQuery.noConflict(true);</script>