23

Today I started work on a new project that contains a lot of legacy. I asked the developers about unit testing javascript and was told that not only is there none in place, but it's not worth adding any in.

At first, I grimaced and thought fair enough. This is their codebase, it's their choice. I've now been thinking about this for a few hours and have instead decided that screw those guys, I'm adding in a testing framework, a module pattern that's compatible with the existing code, and unit testing the crap out of it. If they don't want it they can refactoring it out, but I can't bring myself to intentionally deliver code I know is crap.

I WILL FORCE CODE QUALITY ON THEM.

Comments
  • 3
    "he just came in here and changed everything!"
    Document changes, it'll save your ass when they call you crazy (or review comes up).
    Safe upgradings, :-)
  • 3
    Be careful. You could quickly become an enemy -- the new guy who introduced (what's seen as) a huge burden into their existing dev cycle.

    Look, I'm a proponent testing (meaningful!) JS code. I've implemented it into several projects. None have been kept up, long term. Make sure you know it's laziness -- not wisdom -- that has kept them away from unit testing.
  • 0
    Not trying to discourage good practice - it could be a great change! Sorry, feeling dad-ish this evening 😛
  • 2
    screw it! gj man. thats the only way to go. just know when you should cease and when you should push. little push here, little pull there.
    I'd go BDD first because legacy code isn't always ready to unit test! but I've never tested Js so, what do I know!
  • 0
    I echo @Zyphuris55. Be careful not to cause unnecessary conflict and document everything well so that no one can claim "well I don't know what the hell any of this does".
  • 2
    @Zyphuris55 @zourtney Thanks for the words of caution. This is definitely a case of laziness in my opinion. The dev team are C# devs, with the JS just bolted on. I don't get the impression they care much for it so I'm taking it upon myself to give it some TLC.

    It will be documented, it won't change everything, I'm just going to show them that things can be better without making drastic changes.
  • 0
    @munkyjunky ++ and thanks for the clarification. Good luck!
Add Comment