Remix.run Logo
mrkeen 2 days ago

Maybe I misread. When I see a setUp() in a test suite, 9 times out of 10 it's to handle something shared and bulky, like a database. Otherwise you'd just do the thing - assert(expected, myService.run(input)); If I saw an extra myService.reset() or myService.setUp() I would suspect it's either in anticipation of a bad state (from a previous test) or to be a good neighbour for the next test which will run.

In the cases where each unit test does have it's own individual Postgres or whatever, sure.

aleksiy123 2 days ago | parent [-]

I guess it all depends, isolation isn’t binary.

you can share some things and be isolated across other dimensions.

You could share a Postgres dB connection but just isolate the data logically.

You can isolate or share across individual tests, across suites, across envs, across runs, across time.

More isolation is generally better unless the complexity or cost is too high.

But I guess I was just confused as to how a test requires isolation rather than have it.