Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think auto mocking modules is the most horrible trick a testing framework can pull.

So because you're too lazy to write modules with a minimum of sane dependency injection,you hack require (which is not dependency injection) to mock dependencies?

This is actually the most awfull anti pattern i've seen in javascript land yet.Unfortunatly, it's becoming the "way to go" for most developpers. Instead of making your modules pluggable and decoupled,you negates everything testing is for,you just dont write testable code.



This isn't so bad. Before DI got popular in PHP via Symfony2, we used Zend_Registry. "require" is pretty much the same thing in this context.


what is the effective difference between mocking an injected dependency and a located one?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: