2015-10-05 179 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 
      }); 
     }); 
    });