deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

testing: bdd ".only" option might not work

Open bartlomieju opened this issue 3 years ago • 5 comments

I haven't tested it but here's a report that it might not work: https://www.reddit.com/r/Deno/comments/zchl3q/showcase_my_first_project_in_deno_and_an_early/

bartlomieju avatar Dec 04 '22 18:12 bartlomieju

Thanks, Bartek.

Steps to reproduce:

git clone https://github.com/chooie/hack_assembler
vim src/app/_assembler_test.ts
<where line is 'const test = describe("Assembler");' change it to 'const test = describe.only("Assembler");'
deno test --allow-write --allow-read

Observe that all of the tests still run.

chooie avatar Dec 04 '22 20:12 chooie

Since the describe call is at the top level of the file and not nested in another describe, it should be using Deno.test internally with the only option. Then all other tests in that file would be registered as steps of that Deno.test. If you only ran tests for that file, I would expect them all to run.

I don't remember if this is the case but if Deno.test only option is scoped to a single file, I would expect all tests to still run since there is only 1 Deno.test call for this file. If that is the case, changing Deno.test only option to apply across all files running would resolve the problem for describe/it calls too.

KyleJune avatar Dec 19 '22 08:12 KyleJune

Observe that all of the tests still run.

@chooie I believe only is scoped to the file, so running the entire test suite via deno test --allow-write --allow-read will mean that all the other files will still be run. However, when running on the single file, I'm still getting behavior that I think should be unexpected.

Running deno test --allow-write --allow-read src/app/_assembler_test.ts:

ok | 1 passed (13 steps) | 0 failed (207ms)

After making the following changes:

- const test = describe("Assembler");
+ const test = describe.only("Assembler");
ok | 1 passed | 0 failed | 1 filtered out (39ms)

The only function isn't being ignored. It's actually causing everything in the file to not run.

I believe this issue is happening because there's a symbol created using the describe function which is passed into another describe, rather than an it.

const test = describe.only("Assembler");

describe(test, "Assemble", () => {/* expect to be run, but actually skipped */};

it(test, "Assemble", () => {/* will run as expected */};

This use case looks like it's supported in the code, although not specifically in the documentation.

pting-me avatar Jan 02 '23 02:01 pting-me

I'll be trying out a solution for this one.

pting-me avatar Jan 02 '23 02:01 pting-me

I think this is blocked by https://github.com/denoland/deno/issues/17262

kt3k avatar Jun 26 '24 04:06 kt3k