Hacker News new | ask | show | jobs
by lhorie 1728 days ago

    test("when a metric becomes a target, it stops being a good metric", () => {
      runApp(); // look ma, lots of "coverage"!
      assert(true, 'No errors!');
    }); // unfortunately paraphrased from real code
1 comments

This test will inflate the test coverage, but it is a valid smoke test (assuming that any unhandled exception will cause the test to fail).
You shouldn't write tests like this; there's a high likelihood that the test will be flaky or not representative enough of production, and if the test fails, you often get completely non-actionable error messages.

If you just want to know that your app is broken, it's far better to monitor your live app (or staging environment or deployment pipeline or whatever) since that monitoring infrastructure can then be leveraged to collect other runtime health data in a more granular fashion.