久久久久久久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)用?)
主站蜘蛛池模板: 色综合一区二区三区 | 夜夜精品浪潮av一区二区三区 | 中文字幕精品一区 | 欧美色综合| 婷婷色国产偷v国产偷v小说 | 国产重口老太伦 | 啪一啪 | 国产亚洲欧美日韩精品一区二区三区 | 精品视频99 | 免费观看一级黄色录像 | 中文字幕日韩一区 | 日韩免费一区 | 亚洲一区国产精品 | 免费av一区二区三区 | 久久青| 国产玖玖| 国产色 | 国产高清免费视频 | 欧美激情久久久 | 91av在线免费看 | 91麻豆产精品久久久久久夏晴子 | 国产精品亚洲一区二区三区在线 | 国产激情视频网站 | 欧美精品久久久久 | 亚洲风情在线观看 | 一区二区三区四区毛片 | 亚洲在线 | 精品成人69xx.xyz | 亚洲综合伊人 | av在线一区二区三区 | 日韩精品在线观看一区二区三区 | 97精品久久 | 国产一区二区三区久久久久久久久 | 欧美日韩电影一区二区 | www.日韩| 亚洲综合在线视频 | 在线观看视频一区二区三区 | 久久一级免费视频 | 日本久草 | 国产精品一区二区在线播放 | 欧美一区永久视频免费观看 |