Skip to content

qunit/require-expect with error:except-simple flags tests that contain functions or loops unrelated to any assertions #643

@BillyRayPreachersSon

Description

@BillyRayPreachersSon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions