Mixins created in an addon fail default unit tests


#1

Having an issue with mixins in my addon project. It’s pretty easy to reproduce the bug.

  1. Create a new add on with ember addon mixin-test.
  2. Go into the folder and ember g mixin mymixin.
  3. Run ember test.

I get this error:

not ok 8 PhantomJS 1.9 - TestLoader Failures: dummy/tests/unit/mixins/mytest-test: could not be loaded
    ---
        actual: >
            null
        message: >
            Died on test #1     at http://localhost:7357/assets/test-support.js:2779
                at http://localhost:7357/assets/test-support.js:5541
                at http://localhost:7357/assets/test-loader.js:31
                at http://localhost:7357/assets/test-loader.js:21
                at http://localhost:7357/assets/test-loader.js:40
                at http://localhost:7357/assets/test-support.js:5545: Could not find module `dummy/mixins/mytest` imported from `dummy/tests/unit/mixins/mytest-test`

It looks like the mixin isn’t being properly imported into the test dummy application. I found this issue on StackOverflow that has the same error: http://stackoverflow.com/questions/29320833/ember-cli-0-2-1-generated-addon-test-cannot-find-mixin

But that seems like an issue with upgrading old projects, and it’s supposedly fixed in 0.2.2 which is the version I have.

Here is my version info:

version: 0.2.2
node: 0.12.1
npm: 2.7.4

I was able to deal with the error by creating a file in app/mixins that imports/exports the mixin from the addon folder, but shouldn’t this be done automatically?


#2

I had this same issue with 0.2.3, and fixed it by changing:

import MyMixin from '../../../mixins/my-mixin';

to

import MyMixin from '[addon-name]/mixins/my-mixin';

as explained in this answer: http://stackoverflow.com/a/29600662/223519