Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: bdd ".only" option might not work #2979

Open
bartlomieju opened this issue Dec 4, 2022 · 5 comments
Open

testing: bdd ".only" option might not work #2979

bartlomieju opened this issue Dec 4, 2022 · 5 comments
Labels
bug Something isn't working upstream Changes upstream are required to solve these issues

Comments

@bartlomieju
Copy link
Member

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 bartlomieju added bug Something isn't working needs triage labels Dec 4, 2022
@chooie
Copy link

chooie commented Dec 4, 2022

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.

@KyleJune
Copy link
Contributor

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.

@pting-me
Copy link
Contributor

pting-me commented Jan 2, 2023

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
Copy link
Contributor

pting-me commented Jan 2, 2023

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

@kt3k
Copy link
Member

kt3k commented Jun 26, 2024

I think this is blocked by denoland/deno#17262

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Changes upstream are required to solve these issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants