Hacker News new | ask | show | jobs
by SicSemperUranus 1413 days ago
> never found a legacy JS codebase that has a robust test suite, so any refactoring I do can be hard to test and verify.

Wouldn't you just... make a test suite?

4 comments

If there is no pre-existing test suite, it is extremely difficult to know what is the right expected behavior that should be tested, and what is incidental to the implementation.
Hopefully there is a product team or actual internal users you can interface with to know the expected behavior. I'd expect to at least be able to write some integration-style tests that can ensure everything works from the user's perspective.

If you're so disconnected that you don't know the user's perspective or have no way to see the program in action, then ..best of luck!

Defining big obvious functionality is usually easy to get from people. It's all the finer details that people might not know. You might have a feature that's been relatively untouched for a while, but people still use, so the devs have either left or forgotten from their past "drive-by development".
> just

Legacy code bases are more often that not huge monstrosities. Maybe you do start with some tests and increment, but there's no "just" involved.

Where possible anyway.

I tried adding tests to a legacy AngularJS application (it was in the process of being phased out but was still business critical). I sunk days into trying to get a test to run, let alone pass, before giving up and deciding that eventual replacement was going to be quicker than finding good AngularJS documentation.

> just

Not sure if sarcasm or serious.