jeudi 19 septembre 2019

How to test an ember.js engine route without the ember/no-restricted-resolver-tests eslint error?

My ember.js app uses an in-repo mountable engine called user-backoffice.

This engine provides a route called my-engine-route, and here is the unit test for it, located at my-app/lib/user-backoffice/test-support/unit/my-engine-route/route-test.js

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import engineResolverFor from 'ember-engines/test-support/engine-resolver-for';

const modulePrefix = 'user-backoffice';
const resolver = engineResolverFor(modulePrefix);

module('[user-backoffice] Unit | Route | my-engine-route', function(hooks) {
  setupTest(hooks, {resolver});

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:my-engine-route');
    assert.ok(route);
  });
});

The engineResolverFor part is taken from the ember-engine.com docs.

My problem is that this code generates an eslint error because of the ember/no-restricted-resolver-tests rule.

my-app/lib/user-backoffice/test-support/test-support/unit/my-engine-route/route-test.js
  9:20  error  Do not use setupTest whose last parameter is an object unless used in conjunction with `integration: true`  ember/no-restricted-resolver-tests

In my opinion, the eslint rule and the ember-engine docs are in contradiction, so I'd like to know if the rule should be disabled in an engine's context, or if the ember-engine.com docs should be updated.




Aucun commentaire:

Enregistrer un commentaire