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

it.only inside describe.only run all other its as well #47937

Closed
rluvaton opened this issue May 9, 2023 · 2 comments
Closed

it.only inside describe.only run all other its as well #47937

rluvaton opened this issue May 9, 2023 · 2 comments
Labels
test_runner Issues and PRs related to the test runner subsystem.

Comments

@rluvaton
Copy link
Member

rluvaton commented May 9, 2023

Version

20.1.0

Platform

Darwin my-macOS-1331-my-serial-number.local 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?

run this with node --test-only

const {it, describe} = require('node:test');

describe.only('this is describe', () => {
  it.only('should only run this', () => {
    console.log('test 1');
  });

  it('should not run this', () => {
    console.log('test 2');
  });
});

How often does it reproduce? Is there a required condition?

always

What is the expected behavior? Why is that the expected behavior?

to only log test 1

What do you see instead?

I see that both tests are logged:

test 1
test 2
▶ this is describe
  ✔ should only run this (0.615625ms)
  ✔ should not run this (0.070041ms)
▶ this is describe (1.4065ms)

ℹ tests 2
ℹ suites 1
ℹ pass 2
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 4.498084

Additional information

All I'm trying to do is run a single it that inside a describe

@VoltrexKeyva VoltrexKeyva added the test_runner Issues and PRs related to the test runner subsystem. label May 10, 2023
@rluvaton
Copy link
Member Author

rluvaton commented May 14, 2023

Ping @cjihrig @MoLow

@cjihrig
Copy link
Contributor

cjihrig commented May 14, 2023

It looks like there are two things going on:

  1. Per the docs, the flag only applies to top level tests. This is for the same reason described in having --test and --test-only flags increase prototyping time #47945.
  2. It looks like describe (more specifically, the SuiteContext class) doesn't support t.runOnly(), which is needed for nested "only" tests.

@MoLow MoLow closed this as completed in 5c27cc2 Jun 4, 2023
targos pushed a commit that referenced this issue Jun 5, 2023
PR-URL: #48279
Fixes: #47937
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
danielleadams pushed a commit that referenced this issue Jul 6, 2023
PR-URL: #48279
Fixes: #47937
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
MoLow added a commit to MoLow/node that referenced this issue Jul 6, 2023
PR-URL: nodejs#48279
Fixes: nodejs#47937
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Ceres6 pushed a commit to Ceres6/node that referenced this issue Aug 14, 2023
PR-URL: nodejs#48279
Fixes: nodejs#47937
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Ceres6 pushed a commit to Ceres6/node that referenced this issue Aug 14, 2023
PR-URL: nodejs#48279
Fixes: nodejs#47937
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants