A few notes to inform readers: 1. I am not saying remove the browser from all testing procedures, just unit testing specifically.
- I know about using Node testing frameworks with Jsdom and am not looking for a framework suggestion.
I want to know what people think about unit testing outside of the browser. My main concerns for unit testing using a browser are:
It's slower. This leads to longer feedback loops, devs will run the tests less often and discourages the use of tdd.
Incorporating the DOM is a part of integration testing, right?
Setting up a test environment in a browser can be a pain in the rear. E.g. loading modules and tests, keeping the dom clean, worrying about side effects like XHR, localStorage, cookies etc.
It confuses what we are actually testing at the unit layer. E.g. Am I testing this view renders the elements I'm expecting or am I testing this view renders when I'm expecting it to?
Testing in the browser is important but isn't that the responsibility of integration/functional tests? It makes more sense to me to run unit tests outside of the browser, mock/stub all side effects such as the DOM, XHR etc.
Feedback is appreciated, just looking for some clarity, thanks!