Skip to content

[QUESTION] Namespace set to passed when child status is skipped #546

@MisanthropicBit

Description

@MisanthropicBit

I have a user on neotest-jest (nvim-neotest/neotest-jest#157) who reported that when a namespace is skipped via e.g. describe.skip, the test is correctly marked as skipped but the enclosing namespace is marked as passing. Here is a link to the jest docs on describe.skip and here is an example:

describe.skip("example", () => {
  test("example", () => {
    expect(true).toBe(true)
  })
})

I can reproduce this by running the entire file or the namespace.

Looking through the codebase, I've tracked this behaviour to TestRunner:_missing_results which propagates results upwards through the tree. In propagate_result_upwards, it gets the result from the current node and its parent. If there is no result for the parent (is this case no), it defaults to passed. Then it will only propagate the current node result to the parent if its status is not skipped and the parent status is passed (which is was just set to). In this case, the current node status is skipped so the parent status remains passed.

Just to confirm, I changed the first comparison to pos_result.status == "skipped" and saw that the parent is now correctly set to skipped.

The reason this is a question and not a bug is that this behaviour might be correct for some cases that I'm not aware of. For reference, the line was added in 956ff67 with the message fix(runner): mark files as skipped if no child tests run implying a valid use case. On the other hand, this might be a subtle bug.

I'd be happy to submit a PR if it turns out this is a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions