We've set up our linting for qunit/require-expect
as follows:
'qunit/require-expect': ['error', 'except-simple'],
Given the following two tests - where the only difference is the syntax used to reject after a call to checkThing
, why should the first one be flagged as erroneous?
// Fails linting with ESLint: Should use `expect()` when using assertions outside of the top-level test callback.(qunit/require-expect)
test('checks things', function() {
const service = this.owner.lookup('service:my-service');
service.checkService = EmberObject.create({
checkThing: sinon.stub(() => reject()),
});
service.run();
sinon.assert.calledOnce(service.checkService.checkThing);
});
test('checks things again', function() {
const service = this.owner.lookup('service:my-service');
service.checkService = EmberObject.create({
checkThing: sinon.stub().rejects(),
});
service.run();
sinon.assert.calledOnce(service.checkService.checkThing);
});
As an aside, we've set up our test-helper.js
file to allow Sinon.JS's assertions to count as QUnit assertions, so there's no issue with having no assertions in these tests.