2016-11-27 5 views
0

の私はユニットテストのために次のセットアップを持って約束のオブジェクトを使用する必要があります。は期待し、代わりに解決した結果

const mocha = require('mocha') 
var chai = require('chai') 
var chaiAsPromised = require('chai-as-promised') 
chai.use(chaiAsPromised) 

var expect = chai.expect 
chai.should() 

describe('chain test', function() { 
    it('should be a string', function() { 
    return Promise.resolve('string').should.to.be.a('string'); 
    }); 
}); 

しかし、私はモカを実行すると、結果は次のとおりです。

1) chain test should be a string: 
    AssertionError: expected {} to be a string 

したがって、テストが解決された結果に対してではなく、Promiseオブジェクト自体に対して行われるように見えます。

chai-as-promised: Installation and Setupによれば、設定は正しいです。

そして、chai-as-promised: How to Useに記載されているのと同じ方法でテストが作成されます。

expect(promise).promise.shouldの両方の構文をテストしました。誰もが問題が何であるか知っていますか?

ノードの使用バージョンとモジュールである:

  • ノードv4.6.1
  • チャイ3.5.0
  • チャイ-AS-約束6.0.0
  • モカ3.2.0

答えて

0

私は間違いを発見しました。

問題は、正しい構文が.should.to.beはありませんが、それは、 `.to.`が問題になることができると思います.should.eventually.be

+0

でなければならないことです。 – MarcoL

関連する問題