a unit test is testing a unit (ie: a file). If you feel like the appendThread method should be mocked, then maybe it means that all the DOM operations should be moved to its own unit... (ie: use a more MVC-like model)