Thursday 4 May 2017

Even though my mocha test cases are using should , eslint still warns about it?

I'm using mocha and chai.should assertion library to unit test my OSS npm module. But eslint [v3.18.0^] warns at the should declaration in the code about it not being used

const should = chai.should();

Lint Warning 'should' is assigned a value but never used.

We have mocha as an environment in the .eslintrc. This warning appears despite there being atleast seven assertion statements in my test file like below that have "should" in them.

return sampleModule.getSomeFunction('dummy_accesss_token', 'dummy_event_id').should.eventually.be.eql([]);

I'm aware of the following SO issue which talks about other assertion statments which are never declared while a reply[which was not even declared as the answer] to the query had someone created a plugin to overcome this.

But my basic premise , isnt this a bug in eslint? Atleast "should" should :-) not be flagged since its being used in code [multiple times in my case].



via indcoder

No comments:

Post a Comment