deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

test: write test cases for @std/cli/spinner

Open kt3k opened this issue 1 year ago • 2 comments
trafficstars

It seems possible to write test cases for this module using new Deno.Command().spawn()

kt3k avatar May 02 '24 10:05 kt3k

I'm looking at this. Would I need to create multiple test files in the testdata to be able see different outputs for different scenarios? It seems like I would import Spinner into these testdata files, run different options / scenarios, then run those modules via Deno.Command. I just haven't used Deno.Command a lot. I think this would be a first for tests, so that's why I'm checking first.

    const cmd = new Deno.Command(Deno.execPath(), {
      args: [
        "run",
        // this is where I'd run a testdata file cli/testdata/spinner_tests/<scenario-1>.ts
        ...args,
      ],
      stdout: "piped",
      stderr: "piped",
      ...opts,
    });
    const process = cmd.spawn();
    const output = await process.output();
    // assert(outputStuff)

JakeAve avatar May 10 '24 01:05 JakeAve

Here's what I started. It seems like it'll work, but just feels weird: https://github.com/JakeAve/deno_std/tree/cli-spinner-tests

JakeAve avatar May 10 '24 08:05 JakeAve

done

kt3k avatar May 13 '24 04:05 kt3k