A test is just code that checks code: given this input, expect this output. expect(addTip(100, 10)).toBe(110) is a promise, run the suite and it either holds or fails loudly.
That's why tests upgrade Sam's loop. Reading catches what code says. Running catches what it does tonight. Tests catch what it does every night after, automatically, in seconds, on every future change. The loop just grew a gate.