I'm trying to introduce Unit Test in my development process and I'm not sure how to do it.
I have a big application with a lot of modules ( separated js files ). For example:
- videoInfo.js
- availableVideos.js
- availableChannels.js
- networkSettings.js
- .......
There are also a few modules that provide services for the rest:
- eventHandler.js
- i18n.js
- ajax.js
- configuration.js
- auth.js
- baseModule.js
- ........
The question is: how do I test a module like videoInfo.js that uses all the services modules? I see two approaches:
- I load only videoInfo.js and mock all the internal interfaces. The problem with this is that I won't catch errors if any of the internal interfaces change.
- I load all modules (the whole app) and test the videoInfo with the real app environment ( except the external AJAX calls that will be simulated)
What is the good approach to do this when you have a lot of internal dependencies?