New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moduleForComponent fails "Unable to find partial with name" #110

Closed
saygun opened this Issue Nov 24, 2014 · 8 comments

Comments

Projects
None yet
5 participants
@saygun
Contributor

saygun commented Nov 24, 2014

I have a component that named x-popover. Unit tests for x-popover fails because of this line in x-popover.hbs {{partial "todo-assign-dropdown"}}

It throws error:
Died on test #2 at test (http://localhost:4200/assets/test-support.js:284:13) at eval (app/tests/unit/components/x-popover-test.js:13:5) at requireModule (http://localhost:4200/assets/vendor.js:77:29) at http://localhost:4200/assets/test-loader.js:14:29: Assertion Failed: Unable to find partial with name 'todo-assign-dropdown'.

todo-assign-dropdown is placed in templates folder with name -todo-assign-dropdown.hbs

@tagisen

This comment has been minimized.

Show comment
Hide comment
@tagisen

tagisen Nov 26, 2014

Did you add "todo-assing-dropdown" in needs ?
If your component is has another component as a child, you need to tell qunit that it needs to load those components before it executes the tests.
example:

moduleForComponent 'example-component', 'ExampleComponent', {
    //specify the other units that are required for this test
    needs: ['component:example-depended-component', 'component:some-other-component']
}

tagisen commented Nov 26, 2014

Did you add "todo-assing-dropdown" in needs ?
If your component is has another component as a child, you need to tell qunit that it needs to load those components before it executes the tests.
example:

moduleForComponent 'example-component', 'ExampleComponent', {
    //specify the other units that are required for this test
    needs: ['component:example-depended-component', 'component:some-other-component']
}
@saygun

This comment has been minimized.

Show comment
Hide comment
@saygun

saygun Nov 26, 2014

Contributor

Yes I've added it as component but nothing changed. It is still throwing same error. Actually my todo-assign-dropdown is not a component it is just a partial.

Contributor

saygun commented Nov 26, 2014

Yes I've added it as component but nothing changed. It is still throwing same error. Actually my todo-assign-dropdown is not a component it is just a partial.

@rwjblue

This comment has been minimized.

Show comment
Hide comment
@rwjblue

rwjblue Nov 26, 2014

Member

Basically the issue is that Ember is doing "weird" things for partials (it prepends an underscore). The following is hideous but will get you working for now:

import resolver from '../../helpers/resolver';

moduleForComponent('some-other-thing', 'component:some-other-thing', {
  needs: ['component:some-thing'],

  setup: function(container) {
    container.register('template:path/to/partial', resolver.resolve('template:path/to/-partial'));
  }
});

The factory that Ember (and ember-qunit) is looking for template:path/to/partial does not match the actual module path.

Member

rwjblue commented Nov 26, 2014

Basically the issue is that Ember is doing "weird" things for partials (it prepends an underscore). The following is hideous but will get you working for now:

import resolver from '../../helpers/resolver';

moduleForComponent('some-other-thing', 'component:some-other-thing', {
  needs: ['component:some-thing'],

  setup: function(container) {
    container.register('template:path/to/partial', resolver.resolve('template:path/to/-partial'));
  }
});

The factory that Ember (and ember-qunit) is looking for template:path/to/partial does not match the actual module path.

@saygun

This comment has been minimized.

Show comment
Hide comment
@saygun

saygun Nov 26, 2014

Contributor

Thank you, this solved my problem

Contributor

saygun commented Nov 26, 2014

Thank you, this solved my problem

@saygun saygun closed this Nov 26, 2014

@crazymykl

This comment has been minimized.

Show comment
Hide comment
@crazymykl

crazymykl Dec 16, 2014

Please reopen this issue, this workaround is unsatisfactory, and having two issues tracking the same thing would not be ideal.

crazymykl commented Dec 16, 2014

Please reopen this issue, this workaround is unsatisfactory, and having two issues tracking the same thing would not be ideal.

@saygun saygun reopened this Feb 13, 2015

@saygun

This comment has been minimized.

Show comment
Hide comment
@saygun

saygun Feb 13, 2015

Contributor

@rwjblue This solution is not working anymore. In ember-cli 0.1.15 container in setup function is undefined.

Contributor

saygun commented Feb 13, 2015

@rwjblue This solution is not working anymore. In ember-cli 0.1.15 container in setup function is undefined.

@rwjblue

This comment has been minimized.

Show comment
Hide comment
@rwjblue

rwjblue Feb 13, 2015

Member

The argument is no longer passed in to the 'setup' function, but you can access it via this.container inside the function.

Please review: http://reefpoints.dockyard.com/2015/02/06/ember-qunit-0-2.html for details.

Member

rwjblue commented Feb 13, 2015

The argument is no longer passed in to the 'setup' function, but you can access it via this.container inside the function.

Please review: http://reefpoints.dockyard.com/2015/02/06/ember-qunit-0-2.html for details.

@rwjblue rwjblue closed this Feb 13, 2015

@jboler

This comment has been minimized.

Show comment
Hide comment
@jboler

jboler Oct 23, 2015

@rwjblue I'm getting Uncaught TypeError: this.container.register is not a function

jboler commented Oct 23, 2015

@rwjblue I'm getting Uncaught TypeError: this.container.register is not a function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment