Does zora run async tests in parallel? #117
-
I have a bunch of All of the code is Does zora run tests in parallel?? I didn't think so. It's more than possible I'm doing something seriously wrong on my end 😅 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
They run concurrently (not technically in parallel although I assume that's what you mean in your question). However for some reason, if you want to run a bunch of tests sequencially, you can simply |
Beta Was this translation helpful? Give feedback.
-
Right, I know I can await sub-tests inside a test - but these aren't sub-tests. I can't have top-level await in the target node environment for this project, so the only way to run tests in serial would be to run all my tests from a single file? Hmm, I think, for this project, I'm going to replace the This makes me think again about something I think I may have brought up early on, when I first started using zora: I kind of wish that's what the One reason I switched to this approach in my own framework is because it enabled me to filter the list of tests before running it - for example, this lets me add something like I know you're big on simplicity - and as you know, I am too, but I think our definition of simplicity is not always quite the same. 🙂 In this particular case, I would find it simpler if a test-harness was something you provided with a list of tests and reporter - a pure function with certain inputs and outputs. Instead, we have this Have you ever watched this? Rich Hickey is my simplicity Guru - my views on this stuff completely changed when I first discovered this video. I push it to every developer I know, in the hopes that this world view will catch on... where we draw a hard line between "simple" and "easy" - and with the awareness that favoring "easy" over "simple" usually means taking on extra complexity. Also why I pushed for this and the "frameworks" vs "libraries" distinction, which to my understanding is about control - where "libraries" leave your program in control, "frameworks" generally take control and provide various hooks where it cedes control to you; "frameworks" inherently have more complexity in favor of making something "easy", whereas "libraries" generally have less complexity in favor of keeping things "simple". Zora, as I see it, is somewhere between a library and a framework, whereas Just something to think about. I love zora either way and can find my way around these problems. I just wish the distinction was a little more clear cut, with zora never just "doing things" without your direct say so, but instead being specifically a tool you can "do things with" - leaving pta to the role of "doing things for you". |
Beta Was this translation helpful? Give feedback.
-
So I tried to create my own harness, and I got something that works, but not really the way I wanted or expected. import { createDiffReporter } from "zora-reporters";
import { createHarness, ISpecFunction } from "zora";
import { options } from "./options"; // this module reads various command-line arguments
const tests: Array<{ description: string, spec: ISpecFunction }> = [];
export function test(description: string, spec: ISpecFunction) {
tests.push({ description, spec });
}
export async function runTests() {
const harness = createHarness({});
for (const { description, spec } of tests) {
if (options.debug) {
console.log();
console.log(`-----[ ${description} ]-----`);
}
const result = harness.test(description, spec);
if (options.debug) {
await result; // blocks tests from running in parallel
}
}
await harness.report({
reporter: createDiffReporter(),
});
} What I was expecting here, was I would just copy/paste the built-in harness and work from there - but it relies on internals that aren't available to other modules. So I looked at I was left with no other option besides harnessing the built-in harness. 😄 It works just fine - I now have a function where I can optionally However, this only works for my top-level Writing a true custom harness, rather than wrapping the existing one, would have definitely been my preference - I think this would require exposing things like Any chance you would still consider the |
Beta Was this translation helpful? Give feedback.
They run concurrently (not technically in parallel although I assume that's what you mean in your question).
However for some reason, if you want to run a bunch of tests sequencially, you can simply
await
one to finish as defined in the documentation.the long answer