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

Karma jasmine 測(cè)試:在終端中突出顯示差異

Karma jasmine tests: Highlight diff in terminal(Karma jasmine 測(cè)試:在終端中突出顯示差異)
本文介紹了Karma jasmine 測(cè)試:在終端中突出顯示差異的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

我正在使用 Karma 和 Jasmine 進(jìn)行測(cè)試.在某些測(cè)試中,我有測(cè)試所依賴的大對(duì)象.當(dāng)我做類似的事情時(shí)

expect(obj).toEqual(expectedObj);

obj != expectedObj,我在終端中收到一條錯(cuò)誤消息.但是這個(gè)錯(cuò)誤真的很長(zhǎng),因?yàn)樗藘蓚€(gè)對(duì)象,而且很難看出這兩個(gè)對(duì)象在哪些部分不同.

那么,終端有沒有可以與 karma 一起使用的熒光筆?這樣一來(lái),就更容易找出問(wèn)題所在了.

解決方案

我遇到了同樣的問(wèn)題,對(duì)我來(lái)說(shuō)是

I'm using Karma with Jasmine for my tests. In some tests, I have large objects that the test relies on. When I do something like

expect(obj).toEqual(expectedObj);

and obj != expectedObj, I get an error message in my terminal. But this error is really long, because it includes both of the objects, and it's very hard to see, in what parts the two objects are different.

So, is there any highlighter for the terminal, that can be used along with karma? This way, it would be much more easy to figure out, what's wrong.

解決方案

I had the same problem and what did it for me was karma-jasmine-diff-reporter.

Just install it:

npm install karma-jasmine-diff-reporter --save-dev

and configure it as a reporter, eg:

// karma.conf.js 
module.exports = function(config) {
  config.set({     

    reporters: ['jasmine-diff']     

  });
};

You can configure it to pretty print:

    // karma.conf.js 
    module.exports = function(config) {
      config.set({     

        reporters: ['jasmine-diff'],     

        jasmineDiffReporter: {
            pretty: true, // 2 spaces by default for one indent level
            matchers: {
                toEqual: {
                    pretty: false   // disable pretty print for toEqual
                }
            }
        }         
      });
    };

Output will be something like this:

這篇關(guān)于Karma jasmine 測(cè)試:在終端中突出顯示差異的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 認(rèn)為文檔“準(zhǔn)備好之前,如何讓我的 jasmine 測(cè)試裝置加載?) - IT屋-程序員軟件開發(fā)技術(shù)
What do jasmine runs and waitsFor actually do?(jasmine 運(yùn)行和等待實(shí)際上是做什么的?)
How to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模擬文件來(lái)更改 lt;input type=filegt; 的事件用于單元測(cè)試)
How to unit test a chained method using Jasmine(如何使用 Jasmine 對(duì)鏈?zhǔn)椒椒ㄟM(jìn)行單元測(cè)試)
How do I inject $rootScope into an AngularJS unit test?(如何將 $rootScope 注入 AngularJS 單元測(cè)試?)
Jasmine - How to spy on a function call within a function?(Jasmine - 如何監(jiān)視函數(shù)中的函數(shù)調(diào)用?)
主站蜘蛛池模板: 久久成人18免费网站 | 国产一区二区三区久久久久久久久 | 色婷婷精品久久二区二区蜜臂av | 日本久久久影视 | 在线观看视频一区 | 99精品视频一区二区三区 | 国产农村妇女精品一二区 | 国产一区久久 | 亚洲欧美日本在线 | 成人精品视频免费 | 欧美性受xxxx白人性爽 | 国产一区二区三区 | 中文字幕久久精品 | 国产精品小视频在线观看 | 亚洲天堂日韩精品 | 日日操夜夜摸 | 国产9 9在线 | 中文 | 国产精品3区 | 亚洲精品一区二区三区蜜桃久 | 国产精品伦一区二区三级视频 | 国产成人福利在线观看 | 国产精品一区久久久 | 日韩资源 | 国产精品成人在线 | 精品自拍视频 | 国产美女视频黄 | 99久久亚洲| 色综合九九 | 成人精品免费视频 | 91免费福利视频 | 久久久国产精品网站 | 一区二区三区国产好 | 日韩欧美一区二区三区免费看 | 91精品国产综合久久婷婷香蕉 | 亚洲午夜一区二区 | 欧美日韩精品一区二区 | 99国产精品99久久久久久 | 久久久精品国产 | 欧美一区2区三区3区公司 | 成人精品免费视频 | 9999久久 |