Chapter 4. Testing component methods
This chapter covers
- Testing component methods
- Testing code that uses timer functions
- Using mocks to test code
- Mocking module dependencies
A Vue application without methods is like a smoothie without fruit. Methods contain juicy logic that adds functionality to Vue components, and that logic needs to be tested.
Testing self-contained methods isn’t complicated. But real-world methods often have dependencies, and testing methods with dependencies introduces a world of complexity.
A dependency is any piece of code outside the control of the unit of code that’s under test. Dependencies come in many forms. Browser methods, imported modules, and injected Vue instance properties are common dependencies that you’ll ...