Skip to content
This repository has been archived by the owner on May 26, 2019. It is now read-only.

Update Test Components - Integration Test instead of Unit Test #501

Closed
jimbeaudoin opened this issue Jul 30, 2015 · 9 comments
Closed

Update Test Components - Integration Test instead of Unit Test #501

jimbeaudoin opened this issue Jul 30, 2015 · 9 comments

Comments

@jimbeaudoin
Copy link

Hi,

The section in the guides about Testing Components is using Unit Tests. Since 1.13 the correct way to test components is with an Integration Test right? Also, Ember CLI generate an integration test with a component. My english is not good enough to make a PR but I can create this issue. Sorry! :)

Have a nice day and thank you! :)

@rwjblue
Copy link
Member

rwjblue commented Jul 30, 2015

Yes, using the integration test style described in the following articles is the right way forward:

We should definitely update the guide to support, though that might belong in a different issue (I can't recall if there is one already for this).

@jimbeaudoin
Copy link
Author

Ok, thanks for the links. I appreciate! :) I searched the issue tracker and the PRs but found nothing about this. This is why I decided to open this issue. But I think there is a ember 2.0 guide in the making.

@eccegordo
Copy link

As an aside it would be helpful to clearly discuss the side effects and statefulness of integration testing and explain the difference from unit testing now that there is that integration: true mode for testing components.

After trying to refactor several hundred component tests in my own project I am seeing a lot of of

Uncaught Error: Assertion Failed: calling set on destroyed object

In other tests and through out my app. It seems that integration mode has exposed some underlying issues (I have a lot of data binding). And my hunch is that the integration mode is exposing some problems with the setup and tear down of state.

@trek
Copy link
Member

trek commented Aug 20, 2015

Will try to get a PR addressing this in the coming week

@bantic
Copy link
Member

bantic commented Aug 26, 2015

@trek I'd be happy to write up a PR for this tonight if there's not one already in progress

@lukesargeant
Copy link

Why are we refactoring component unit tests? Don't component integration tests perform a different role?

@toddjordan
Copy link
Contributor

At my day job, we are starting to incorporate integration-component tests as we develop new components. Some things we are working through are how to deal with things like service dependencies, as well as convert/adapt our existing component unit tests to things like closure actions. I've got time today and this weekend, so I'll start writing up a guide page. I'll PR that into here if help is still wanted, but if anything it will help out the team I work on.

@toddjordan
Copy link
Contributor

A couple of notes on how I'm going about it...

  • I'm using the same examples that are currently there (pretty-color, magic-title, comment-form), just now doing it the integration way (rendering with hbs). Creating a simple app on the side to verify them.
  • In the testing actions section I'll be using closure actions instead of sendAction
  • I might also add a section on external services. For example our team has a web socket-based service where stubbing at the http request level is not trivial. Instead we want to just register a fake service to handle interactions. I'm still thinking through the details on what needs to be said for this example. I may do that in a separate PR, since that I'd imagine will need some more input.
  • I'm also wondering if its worth adding a section for folks who have existing component unit tests and are migrating to Ember 2. Once you switch over to closure actions its going to change the way you stub actions. For example instead of setting targetObject we set functions on the attrs object.

@toddjordan
Copy link
Contributor

Created a pull request for converting existing component unit test examples to integration tests: #774

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants