Skip to content

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

Description

@rluvaton

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

Activity

  1. rluvaton commented on May 14, 2023

    @rluvaton
    MemberAuthor
  2. cjihrig commented on May 14, 2023

    @cjihrig
    Contributor

    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.
  3. added a commit that references this issue on Jun 5, 2023
  4. added a commit that references this issue on Jul 6, 2023
  5. added a commit that references this issue on Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions