Skip to content

errors thrown in describe() do not set non-zero exitCode (and do not fail CI) #58687

Description

@ChALkeR

Version

v24.2.0

Platform

Darwin 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:34:14 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T8122 arm64

Subsystem

test

What steps will reproduce the bug?

import { describe, test } from 'node:test'
import assert from 'node:assert/strict'

describe('green', () => {
  test('one', () => {
    assert(1 === 1)
  })
})

describe('red', () => {
  test_('one', () => {
    assert(1 === 1)
  })

  test('two', () => {
    assert(1 === 2)
  })
})

node --test foo.js; echo $?

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

Every time

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

A test failure printed and a non-zero exit code upon test termination

What do you see instead?

A test failure printed but the exit code is zero, the test is effectively treated as passing by tooling / CI

Additional information

A work-around using a custom reporter is possible, see ExodusOSS/test@7493701

Activity

  1. added
    test_runnerIssues and PRs related to the test runner subsystem.
    on Feb 3, 2026
  2. ChALkeR commented on Feb 26, 2026

    @ChALkeR
    MemberAuthor

    cc @nodejs/test_runner ?

  3. JakobJingleheimer commented on Feb 26, 2026

    @JakobJingleheimer
    Member

    Is this perhaps caused by mixing test with describe? I think I've not tried to do that; I'm not sure it's supported.

  4. ChALkeR commented on Feb 26, 2026

    @ChALkeR
    MemberAuthor

    @JakobJingleheimer No, this assumes legitimate usecase.

    E.g. assume some lib uses node:test for tests
    And has some preparation steps in descripe, e.g. a function call or a library import. Or test data creation.
    Or e.g. mock.module( call (which Node.js tests do:)
    That was not expected to throw

    And then as a result of or a regression in that lib that code begins to throw (e.g. a file gets renamed and mock.module can't find it anymore)

    But node:test in CI will mark it as passing because if describe() itself throws and no tests are run, that counts as passing
    Even though is reported as failing in the logs.

  5. JakobJingleheimer commented on Feb 26, 2026

    @JakobJingleheimer
    Member

    There is no preparation in the reproduction in your OP. Could you please update your OP to reflect what you just described.

  6. ChALkeR commented on Feb 26, 2026

    @ChALkeR
    MemberAuthor

    @JakobJingleheimer There is mistype in test_. Which demonstrates this just fine once you run it?

    The test fails but is reported as passing.
    Tests should not be marked as passing when the user makes a mistype in test(.

    Any error during describe( reproduces it

    I'm unsure how adding more examples (of various errors that could happen during describe() under attempted normal usage) to the demo would help if the issue should be clear as is

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