emberjs / ember.js

Ember.js - A JavaScript framework for creating ambitious web applications
https://emberjs.com
MIT License
22.47k stars 4.21k forks source link

Generated addon tests should import from addon module namespace #16843

Open mike-north opened 6 years ago

mike-north commented 6 years ago

Currently, mixin-tests generated within an external addon import their respective mixins directly from the /addon namespace like this;

import FooMixin from 'my-addon/mixins/foo';

This is the intended pattern. Several other types of tests (all of which import the thing being tested) import from the dummy app

import { fooHelper } from 'dummy/helpers/foo';

We should make generated tests consistent and correct in this area by fixing blueprints and blueprint tests.

Known sites where this happens

Util Tests

https://github.com/emberjs/ember.js/blob/04208064f8ecf4d9a31a428090191b37859be08c/node-tests/fixtures/util-test/dummy.js#L1

Initializer Tests

https://github.com/emberjs/ember.js/blob/04208064f8ecf4d9a31a428090191b37859be08c/node-tests/fixtures/instance-initializer-test/dummy.js#L3

Helper Unit Tests

https://github.com/emberjs/ember.js/blob/04208064f8ecf4d9a31a428090191b37859be08c/blueprints/helper-test/qunit-rfc-232-files/tests/__testType__/helpers/__name__-test.js#L17

related: #16841

rwjblue commented 5 years ago

Totally agree, addon generated tests should always be importing from the addon namespace (not the dummy app). Definitely happy to get PR's for this.

Lots of work in the blueprint space has been happening since this was originally opened, and I'm not sure if all of the examples of "bad cases" are still applicable. I think the first step would be to review the full list of blueprints that ember-source provides and check what each of them do when used in an addon.

mike-north commented 5 years ago

I think the first step would be to review the full list of blueprints that ember-source provides and check what each of them do when used in an addon.

At the very least, the examples enumerated above have not yet been fixed