Chapter 13. Component testing
This chapter covers
- Running tests with the Web Component Tester (WCT)
- Using Mocha and Chai for creating tests
- Alternate test running with Karma and Karma Web Components
Before we consider the color picker component finished, there is one additional step that should really be taken into account. It’s not a step that everyone puts effort into, but testing can go a long way in terms of how much the component can be trusted and how easy it is to maintain. The same can be said for almost anything you make in software development.
Testing can be broken down in many ways, but one of those ways is functional versus unit testing. The lines between these can get fairly blurry, but unit testing typically involves taking a piece of code that does one single thing, or a unit, and running a series of tests on it to make sure it doesn’t fall down for some edge case that wasn’t considered during development. Functional testing, on the other hand, involves testing a specific piece of functionality that is expected by the user—it’s not making sure the code does the right things, only that the application does.