-
-
Notifications
You must be signed in to change notification settings - Fork 868
Improve integration test helpers documentation #562
Comments
This can be related to #501 |
One other thing that is not clear from the guides is how to stub out services as part of integration tests. In my particular case I have some service objects that are injected into specific components. But the components tests fail because the service object is not properly setup and torn down. It would be nice to know how to mock these services with a test helper that works with component integration mode tests. Faking out a specific API endpoint for example. |
I'm also having an issue trying to stub a service that's being injected in a component. I have a couple ideas of how to do this, but they all seem hacky. Would be nice to have some clarification on how to achieve stubbing services. |
The easiest work around/fix is to use Ember.inject.service in your component and remove the initializer. |
I'm going to close this out for now - I'm not totally sure whether this belongs in the Guides, API docs, or a blog post/etc outside of official Ember stuff, but it doesn't seem like a high priority. I'm totally happy to review a pull request if somebody wants to put something together, although it might be best to start it as a blog post and then open a PR. @toddjordan you've been super helpful with reviewing the existing testing materials - do you have any thoughts on this, or on any other content you think is missing from the Testing section? |
@michaelrkn For the part on stubbing services in the comments above, I actually have a branch on my fork (toddjordan@0730c86) that I was planning PR onto component testing as part of its own issue. The thing I need clarification for is I'm not sure if the way I'm registering and looking up stub services is using things that are public an sanctioned. I can open an issue for stubbing services and PR my change and try to get feedback from some of our core team. |
@toddjordan 👍 on both counts! |
It seems that there needs be a section on "Integration Test Helpers". That discuss how to build a custom helper for integration testing of components.
For example:
Imagine I have a useful but repetitive little bit of code throughout my component tests
What is not clearly documented is how I could create and use a helper in my integration tests.
I would like to do something like this
The goal being to DRY up test logic. The current guides have
test helpers
andunit test helpers
but nointegration test helpers
.I believe the above doesn't work for me because of the
startApp
stuff doesn't seem to be available when in integration mode for tests.That being said a lot more love could be given to test story overall. In Ember testing is still far more painful than it should be. Need MOAR examples!
The text was updated successfully, but these errors were encountered: