When testing for expected strings, I typically assert explicit strings, not...


When testing for expected strings, I typically assert explicit strings, not the result of function invocations.

Example:

Here’s why:
- Asserting for an explicit, static value makes the test easier to read.

- If the function’s output changes, the test will fail. That’s a good thing. It assures we're aware of the change so we can validate the new output is right and update the test.

View original on X