![Peer Dependencies](http://img.shields.io/david/peer/dbrockman/eslint-plugin-should-promised.svg?style=flat)
eslint-plugin-should-promised
Eslint rule for checking that should-promised assertions return
Install
$ npm i -D eslint-plugin-should-promised
Configure
{
"plugins": [
"should-promised"
],
"rules": {
"should-promised/return-promise": 2
}
}
Rules
Require promise assertions to return (return-promise)
This rule is intended to be used with the should-promised plugin for the should assertion library.
When testing an async function by returning a promise to mocha it is important to remember to actually return the promise. Forgetting to return will not cause the test case to fail.
This rule will point out when a should-promised assertion is made without returning.
Rule Details
This rule looks for any of the properties Promise
, fulfilled
, fulfilledWith
, rejected
, rejectedWith
, finally
and eventually
.
The following patterns are considered warnings:
describe('forgot to return the promise', function() {
it('warn when not returning the promise from should.be.fulfilled', function() {
thing.fn().should.be.fulfilled();
});
it('warn when not returning the promise from should.eventually', function() {
thing.fn().should.eventually.eql(1);
});
});
These patterns would not be considered warnings:
describe('forgot to return the promise', function() {
it('warn when not returning the promise from should.be.fulfilled', function() {
return thing.fn().should.be.fulfilled();
});
it('warn when not returning the promise from should.eventually', function() {
return thing.fn().should.eventually.eql(1);
});
});
Further Reading