I have the following setup for my unit testing:
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');
});
});
But when I run mocha, then the result is:
1) chain test should be a string:
AssertionError: expected {} to be a string
So it seems as if the test is done against the Promise object itself and not against the resolved result.
According to chai-as-promised: Installation and Setup the setup is correct.
And the test is created the same way as described in chai-as-promised: How to Use.
I have tested both the expect(promise).
and the promise.should
syntax. Does anyone know what the problem could be?
The used versions of node and the modules are:
- node v4.6.1
- chai 3.5.0
- chai-as-promised 6.0.0
- mocha 3.2.0