By default, a component generated by ember-cli will have an integration test created for it as well. These are very useful for testing the functionality of you component. The problem with integration tests is that they do not provide the granular level of testing we would get from a unit test. I often find that I’d like to pass a number of different values at my computed Properties to ensure they are behaving as expected. This is where the component unit test comes in.
A component unit test can be generated by providing the --unit flag to the ember-cli generator.
The generated test will look like this:
The newly created test is strange. It’s a unit test, but is rendering the component? That’s a bit odd; The good part is, if we remove the line this.render() and the assertion assert.equal(this.$().text().trim(), ''); this becomes a proper unit test. Here’s a quick example.