久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

BlanketJS + Jasmine 2.0 不工作

BlanketJS + Jasmine 2.0 not working(BlanketJS + Jasmine 2.0 不工作)
本文介紹了BlanketJS + Jasmine 2.0 不工作的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我一直在使用 Jasmine 2.0.0 進行測試,它可以正常工作.但是當我將 BlanketJS 附加到我的代碼時出現了問題.

I have been testing with Jasmine 2.0.0 and it works without any problem. But there's a problem when I append BlanketJS to my code.

我使用了一個 specRunner(https://github.com/alex-seville/blanket/blob/master/test/jasmine-requirejs/runner.html)適用于 Jasmine 1.3.1.但是當我用 Jasmine 2.0.0 替換 Jasmine 1.3.1 時它不起作用,

I used a specRunner(https://github.com/alex-seville/blanket/blob/master/test/jasmine-requirejs/runner.html) that works with Jasmine 1.3.1. But It does not work when I replace Jasmine 1.3.1 with Jasmine 2.0.0,

這是來自 BlanketJS 存儲庫的原始代碼:

Here's original code from BlanketJS repo:

<html>
<head>
<title>Jasmine Spec Runner</title>
<link rel="stylesheet" type="text/css" href="../vendor/jasmine.css">
<script type="text/javascript" src="../vendor/jasmine.js"></script>
<script type="text/javascript" src="../vendor/jasmine-html.js"></script>
<script type="text/javascript" src="../helpers/console_runner.js"></script>
<script type="text/javascript" src="../../node_modules/requirejs/require.js"></script>
<script type="text/javascript" data-cover-only="code/" data-cover-never="['all.tests','code/tests']" 
src="../../dist/qunit/blanket.js"> </script>
<script type="text/javascript" src="../../src/adapters/jasmine-blanket.js"></script>

<script type="text/javascript">
    if (window.require && typeof (window.require.config) === 'function') {
        require.config({
            baseUrl: './code'
        });
    }
</script>
<script type="text/javascript" src="code/all.tests.jasmine.js"></script>

<script type="text/javascript">
    (function () {
        window.blanketTestJasmineExpected=2;

        var jasmineEnv = jasmine.getEnv();
        jasmineEnv.updateInterval = 1000;

        var htmlReporter = new jasmine.HtmlReporter();
        var oldResult = htmlReporter.reportRunnerResults;

        jasmineEnv.addReporter(htmlReporter);

         /* this is just for our automated tests */
          window.jasmine_phantom_reporter = new jasmine.ConsoleReporter;

          jasmineEnv.addReporter(jasmine_phantom_reporter);
          /*   */

        jasmineEnv.specFilter = function (spec) {
            return htmlReporter.specFilter(spec);
        };

        var currentWindowOnload = window.onload;
         window.onload = function() {
            if (currentWindowOnload) {
              currentWindowOnload();
            }
            execJasmine();


          };

          function execJasmine() {
            jasmineEnv.execute();
          }

    })();
</script>
</head>
<body>
</body>
</html>

我添加了 Jasmine 2.0.0 文件并更改了如下代碼:

and I added Jasmine 2.0.0 files and changed this code like below:

....
<title>Jasmine Spec Runner</title>
<link rel="stylesheet" type="text/css" href="../vendor/jasmine.css">
<script type="text/javascript" src="../vendor/jasmine-2.0.0/jasmine.js"></script>
<script type="text/javascript" src="../vendor/jasmine-2.0.0/jasmine-html.js"></script>
<script type="text/javascript" src="../vendor/jasmine-2.0.0/boot.js"></script>
<script type="text/javascript" src="../helpers/console_runner.js"></script>
....

打印的錯誤信息:

Uncaught TypeError: Cannot read property 'env' of undefined jasmine-html.js:38
Uncaught TypeError: Object #<Env> has no method 'currentRunner' jasmine-blanket.js:76

我怎樣才能順利運行這個 specRunner 頁面?請給我一個解決方案.謝謝.

How can I run this specRunner page without problems? Please give me a solution. thanks.

推薦答案

Blanket 適配器使用 currentRunner 但在 2.0 中不再存在.Blanket Jasmine 適配器需要更新,因為這和報告器界面都已更改.

the Blanket adapter uses currentRunner but that doesn't exist in 2.0 anymore. The Blanket Jasmine adapter needs to be updated as both this and the reporter interface has changed.

打開你的 jasmine-blanket.js 文件并將底部的代碼替換為:

Open up your jasmine-blanket.js file and replace the code at the bottom with this:

BlanketReporter.prototype = {
        specStarted: function(spec) {
            blanket.onTestStart();
        },

        specDone: function(result) {
            var passed = result.status === "passed" ? 1 : 0;
            blanket.onTestDone(1,passed);
        },

        jasmineDone: function() {
            blanket.onTestsDone();
        },

        log: function(str) {
            var console = jasmine.getGlobal().console;

            if (console && console.log) {
                console.log(str);
            }
        }
    };

    // export public
    jasmine.BlanketReporter = BlanketReporter;

    //override existing jasmine execute
    var originalJasmineExecute = jasmine.getEnv().execute;
    jasmine.getEnv().execute = function(){ console.log("waiting for blanket..."); };


    blanket.beforeStartTestRunner({
        checkRequirejs:true,
        callback:function(){
            jasmine.getEnv().addReporter(new jasmine.BlanketReporter());
            jasmine.getEnv().execute = originalJasmineExecute;
            jasmine.getEnv().execute();
        }
    });

那么它應該會按預期進行.

Then it will should as intended.

ETA - 我個人會改用伊斯坦布爾,因為毯子現在似乎很少更新(如果有的話).伊斯坦布爾擁有更完整的覆蓋率統計數據(不僅僅是線路 - 分支等),并且可以導出到 lcov 以獲取 Code Climate 等工具.它可以與 Jasmine 或任何測試框架完美配合.

這篇關于BlanketJS + Jasmine 2.0 不工作的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 認為文檔“準備好之前,如何讓我的 jasmine 測試裝置加載?) - IT屋-程序員軟件開發技術
What do jasmine runs and waitsFor actually do?(jasmine 運行和等待實際上是做什么的?)
How to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模擬文件來更改 lt;input type=filegt; 的事件用于單元測試)
How to unit test a chained method using Jasmine(如何使用 Jasmine 對鏈式方法進行單元測試)
How do I inject $rootScope into an AngularJS unit test?(如何將 $rootScope 注入 AngularJS 單元測試?)
Jasmine - How to spy on a function call within a function?(Jasmine - 如何監視函數中的函數調用?)
主站蜘蛛池模板: 久久不卡日韩美女 | 新疆少妇videos高潮 | 久久高清免费视频 | 精品无码三级在线观看视频 | 久久久久久久一区二区三区 | 国产激情在线 | 亚洲人在线观看视频 | 亚洲一区中文字幕 | 波多野结衣av中文字幕 | 免费成人毛片 | 精品美女久久久久久免费 | 一区二区在线免费观看视频 | 午夜精品影院 | 密室大逃脱第六季大神版在线观看 | 国产91成人| 欧美一区二区三区在线视频 | 99pao成人国产永久免费视频 | 亚洲成人精品在线 | 欧美看片| 精品视频在线观看 | 久久福利 | 欧美大片一区二区 | 成人区精品一区二区婷婷 | 久操福利| 四虎在线视频 | 看黄在线| 三级特黄特色视频 | 国产电影一区二区 | 精品欧美乱码久久久久久 | 天天天操 | 中文久久| 一区二区在线看 | 91资源在线播放 | 国产在线不卡 | av黄在线观看 | 国产精品区一区二区三区 | www.夜夜骑 | 91精品福利 | 国产日产精品一区二区三区四区 | 欧美成人精品激情在线观看 | 成人国产精品 |