-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Is not finding factories that are in tests/factories/ #74
Comments
The factories are only imported if you use the startApp call in your test.
I am guessing you are not doing that, but using moduleForModel kind of test .. right? |
Right I'm not doing that. Is there a less "heavy" way of getting all of my factories included? I'm doing this: import Ember from 'ember'; moduleForComponent('form-inputs/text-field', { test('it renders', function(assert) { debugger; //var component = this.subject({ // creates the component instance //Ember.run(function() { //assert.equal(component._state, 'preRender'); //this.render(); //debugger; // renders the component to the page |
Yeah .. I hear you on that one. I will cook up a method that will import the factories whenever you want to do that. `import Em from 'ember'`
`import { make } from 'ember-data-factory-guy'`
`import TestHelper from '../helpers/view-test-helper'`
`import startApp from '../helpers/start-app'`
`import {describeComponent} from 'ember-mocha'`
describeComponent 'hsl-input', 'HslInput', ->
App = null
component = null
beforeEach ->
Em.run ->
App = startApp()
TestHelper.setup()
afterEach ->
Em.run ->
TestHelper.teardown()
App.destroy()
hslViewValues = ->
[
find('.h input').val(),
find('.s input').val(),
find('.l input').val()
]
setupComponent = (scope)->
component = scope.subject()
mkt = make('marketing')
component.set('model', mkt)
scope.render()
it "change to color shows in values", ->
setupComponent(this)
expect(hslViewValues()).to.arrayEqual([240,100,50])
mkt.set('color', 'black')
expect(hslViewValues()).to.arrayEqual([0,0,0]) When I am done with that I will bump up patch version and let you know. As an aside: The problem with using moduleForModel ( not true for moduleForComponent ) is that you have to also manually needs: [] every model that is referenced in belongsTo/hasMany .. which gets really tedious. |
Does startApp also set the store? I keep getting: at Object.TestLoader.loadModules (http://localhost:4201/assets/test-loader.js:21:18): Assertion Failed: FactoryGuy does not have the application's store. Use FactoryGuy.setStore(store) before making any fixtures I appreciate your feedback and help. Reading the readme using FactoryGuy seemed a simple and easy solution to mocks etc, but I've spent 2 days trying to get this to work and am losing hope. The get() method in the following line fails: Ember.run(function() { Is this also a startApp issue? If I need to use startApp in all of my tests that use FactoryGuy I can try to figure that out, but an example startApp file implementing this would be really helpful. |
Yes, it does. And take a look at the Sample model test (user-test.js): in the "dummy" application in the ember-data-factory-guy github repo. |
So, to expand a bit. When you starApp() the way I am doing "start the application" FactoryGuy sets the store automatically, and then loads the factories. |
I don't mind doing the startApp, if that's the way you've made things work. I can't remember if you mention to do that in the Readme, but if you make sure to mention that, it will safe some people some headache for sure. Thanks so much for your help. |
Good point, I will add that in the documentation .. so it's less confusing, because I did not really explain that clearly. |
Thanks, if you don't mind, I'll run by some other issues I'm having, since others may be having them too, and at this page will be indexed and people might stumble on the solutions :) This line fails from the docs: TestHelper.handleUpdate('person', person.id); --> TestHelper is not defined |
Oops, my mistake.. if the comment above I had this:
should have said this:
I created a custom TestHelper that overrode the original ( the view-test-helper ) |
Also .. you don't have to do that
if you have the person model as you do, you can do this: TestHelper.handleUpdate(person) |
yes.. that last part would not show in 'code' style .. hmm |
:-) |
Ok, but TestHelper is not defined |
even with this import:
|
No, with that, it works, but this is what people need in the docs, otherwise that object comes out of nowhere. |
Hmm .. yeah .. I know what your saying. It is in the docs, in the very end ( acceptance test ) |
Thanks for all your help! |
Your welcome, and thanks for taking the time to document the issues. As you say, it helps everyone else too. |
@pixelterra .. I just updated the documentation to show a component test example, |
I am having to manually include any factory file that I want to use. I can see the there is some kind of initializer in the source that is supposed to load them, but this doesn't seem to run. It ends up being commented out in my vendor.js
The text was updated successfully, but these errors were encountered: