A professional test is recognized not by being green but by staying useful a year later - when the code is rewritten and the team has changed, the check will still catch regressions and still not fire falsely. Below are eight marks of such a test; together they add up not to a checklist to tick but to one principle: a test must speak about the system's behavior truthfully and durably.
It starts with the name. A good test name is a sentence with a condition and an observable outcome: returns 409 when the cart is empty, not checkout test. From a single failed name in the CI log it should be clear what broke, without opening the file. And a test must check behavior, not a private call: not the calcTotal method was called, but the order total equals 120. Checking an internal call cements the implementation - rename the private method and the test goes red though the user noticed nothing.
A single happy path proves nothing. A professional set takes four classes of input: normal (an ordinary cart with a couple of items), boundary (an empty cart, exactly one item, the maximum at the limit), invalid (a negative quantity, an unknown SKU), and failure (the payment gateway returned an error). Regressions live precisely on the boundaries and in the failures, not in the middle of the range you check by instinct.
A test must not depend on what you do not control. The network is replaced by a mock at the boundary, the clock by fake timers and a fixed date, so an order placed at 23:59 does not fail overnight. It must not rely on run order or on state left by a neighbor: beforeEach returns the world to its initial state, clearMocks wipes the mock history. A test that depends on those four things - network, clock, order, someone else's state - will sooner or later turn flaky.
A mock is placed at a real architectural boundary - where your code talks to the outside world: an HTTP client, a database driver, a payment SDK. Mocking your own business logic is pointless - you will check the stub, not the product. And be careful with substitution: if the whole risk is in how the cart module really goes to the database, a unit mock of that database removes exactly what was worth checking. Such a risk is checked with an integration test at the real (if test) boundary, not mocked through.
On failing, a test must give a clear diff. toEqual on the order object shows which field diverged; toThrow with a concrete error type - what threw wrongly. An assert on one vague boolean (expect(ok).toBe(true)) says nothing in the log beyond false, expected true. Diagnosability of a failure is not decoration but half the test's value: a test exists to show the cause within seconds at the moment of breakage.
The final check is a thought experiment: if you rewrite the internals without changing observable behavior, the test must stay green. Red on a safe refactor means the test is nailed to the implementation, not the contract, and will obstruct the code's evolution. The eight marks reduce to one: a test describes what the system does for the user and stays silent about exactly how. Such a test outlives its code - and that is the whole job. Lean on the official Jest 30.4 and Testing Library docs, not on guesses about the API - that is what separates a professional check from superstition.