Published on April 17, 2016 by Toran Billups
As a continued effort to share some popular questions from my workshop at EmberConf last month I'm pushing ahead with another post on integration testing components. In the next few weeks I hope to share some useful test cases that I can more easily find/share with people as they seem to come up so often.
In the question/answer today I hope to show how you register a component/template and use it in a test when the dynamic component helper is used. In this short example we need to render a custom component when a "custom" template name is passed in. This would allow the production app to render a dynamic view of the same data for example.
In the test cases below you can see the first scenario shows a simple "not configured" example and it's not very unique or special. The interesting part of the second test is how we can register/or inject a custom component just for this test case. With the template configured this time around, we can watch how the component responds as we render it using the custom component helper.
If you wanted to take this a step further you could write a special test that shows the runtime will indeed blow up if you try to render a component that is not available.
To see the tests in action you can pull down this example app to learn more