0
votes

I have recently upgraded ember-cli 0.2.0 to 0.2.1 and I ran the following command to generate a mixin:

ember g mixin listener

The generate file was place in addon/mixins/listener.js.

The generated test looks like this:

import Ember from 'ember';
import ListenerMixin from '../../../mixins/listener';
import { module, test } from 'qunit';

module('ListenerMixin');

// Replace this with your real tests.
test('it works', function(assert) {
  var ListenerObject = Ember.Object.extend(ListenerMixin);
  var subject = ListenerObject.create();
  assert.ok(subject);
});

The test fails with the following error message:

Could not find module dummy/mixins/listener imported from dummy/tests/unit/mixins/listener-test

My mixins should be in /addons/ and not /app/

What do I need to change for the tests to find the module?

When I upgraded from 0.2.0 to 0.2.1 I followed the docs for upgrading and ran all the steps in the docs

but this line:

ember init

Returned this error which I assume is something to do with it:

Generating an addon in an existing ember-cli project is not supported.

3
The error you mentioned on init was recently fixed but has not been released yet. Should be in the next version. - steveax

3 Answers

4
votes

I ran into this issue on Ember-CLI 0.2.3 and it appears the resolver still has a problem with Mixins that are part of an addon. I solved this by replacing Ember-CLI's default:

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

to ...

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

Works for me. Hope it works for you too.

1
votes

You can create another mixin in the app tree, to be merged with the parent app's tree.

import ListenerMixin from 'addon-name/mixins/listener';

export default ListenerMixin;

and if you don't want that, you'll need to change this line: module('ListenerMixin'); as that tries to find that module in the app tree. You might also change line 2 to import ListenerMixin from 'addon-name/mixins/listener';

0
votes

This may be a known issue with [email protected] and is currently being investigated: https://github.com/ember-cli/ember-cli/issues/4633