2015-10-05 178 views
0

所以我有一個非常基本的測試,我想檢查使用茉莉花的測試中的Promise響應的類型。我運行一個節點項目,並有所有這些細節設置承諾沒有顯示測試結果的茉莉花

describe('fail assertion', function() { 
     it('should be a failure', function(done) { 
      myvideopromise.then(function(resp) { 
       expect(true).toBe(false); 
       done(); 
      }).catch(done); 
     }); 
    }); 

describe('list videos', function() { 
     it('should return a list of videos', function(done) { 
      myvideopromise.then(function(videos) { 
       expect(Array.isArray(videos)).toBe(true); 
       done(); 
      }).catch(done); 
     }); 
    }); 

但是當我運行它,我只是看到這下面。

Started 
F. 

Failures: 
1) video suite fail assertion should be a failure 
    Message: 
    Expected true to be false. 

「F」是紅色的,「。」是綠色的。因此,它似乎正確地運行測試斷言,但對於成功,它似乎並沒有顯示成功信息。是否有我需要通過的標誌或什麼?我使用

jasmine JASMINE_CONFIG_PATH=test/jasmine_config.json 

而且我jasmine_config.json文件只是看起來調用它像

{ 
    "spec_dir": "test/other/", 
    "spec_files": [ 
     "video_tests.js" 
    ] 
} 
+0

[在量角器測試自定義茉莉花記者]的可能的複製(HTTP://計算器.com/questions/23677986/custom-jasmine-reporter-in-massractor-tests) – mido

+0

我試着將這些字段設置爲true,他們似乎沒有做任何事情 –

回答

0
describe('fail assertion', function() { 
     it('should be a failure', function (done) { 
      myvideopromise.then(function (resp) { 
       expect(true).toBe(true); 
       done(); 
      }).catch(e => { 
       done(e); 
      }); 
     }); 
    }); 

    describe('list videos', function() { 
     it('should return a list of videos', function (done) { 
      myvideopromise.then(function (videos) { 
       expect(Array.isArray(videos)).toBe(true); 
       done(); 
      }).catch(e => { 
       done(e);// it's a failure case 
      }); 
     }); 
    });