kaocha

reefersleep 2025-11-07T10:48:13.843459Z

Hello 🙂 Does Kaocha run tests in parallel?

reefersleep 2025-11-07T10:50:00.345789Z

I've been debugging some behaviour that seems to result from a fixture setting a global var to X before the test, then resetting it to Y after. And it seems like for some random amount of tests on reach run using this fixture, they see Y.

2025-11-07T11:11:37.865299Z

Kaocha runs the tests in a random order. This probably means that one or more of your tests have side effects that affect the tests being run after it. You can reproduce the same order using a given random seed.

âž• 1
reefersleep 2025-11-07T12:10:51.291159Z

Ah, the fixture is used :once , that is once for a namespace. If kaocha interleaves tests from different namespaces when running them, this can explain the fixture side-affecting the global var at an unfortunate time.

reefersleep 2025-11-07T12:11:02.095679Z

So, switching to :each should also fix it.

reefersleep 2025-11-07T12:15:59.066229Z

It does! Thank you @magnars, this was very enlightening 🙂

😊 1
plexus 2025-11-07T13:29:48.930589Z

it wouldn't interleave different namespaces. Randomization happens on each level of nesting, so if you have multiple test suites, they run in a random order. For each test suite the namespaces run in a random order, and for each namespace, tests within them run in a random order. We have a big old PR that adds actual parallelism... it's kind of experimental. Feedback from people actually using it would be welcome.

reefersleep 2025-11-07T17:11:32.311399Z

What you're saying means my issue isn't yet explained, then, @plexus ... Since I'm seeing the error when instrumenting :once per namespace. But instrumenting :each fixes the issue.

reefersleep 2025-11-08T10:22:08.512979Z

Will investigate further the coming week. From what you're saying, it sounds unrelated to Kaocha.