Skip to content

beforeAll silently swallows error: Test failed because the "only" option was used #6998

@dandv

Description

@dandv

Describe the bug

If a test file has a beforeAll hook and a test.only, the error: Test failed because the "only" option was used that Deno normally displays is silently swallowed.

This is dangerous in CI/CD pipelines if a developer accidentally commits a test.only(...) because it would cause CI to pass without any warnings, skipping all other tests in the file.

Steps to Reproduce

import { beforeAll, describe, test } from "@std/testing/bdd";

beforeAll(() => {
  console.log("beforeAll: setup runs here");
});

// describe("suite A", () => {  // the error is swallowed with or without the outer describe block
  test("test A1", () => {
    console.log("test A1 ran");
  });

  test.only("test A2 - FOCUSED", () => {
    console.log("test A2 ran (focused with .only)");
  });

  test("test A3", () => {
    console.log("test A3 ran");
  });
// });

Expected behavior

Deno should always show the error "Test failed because the 'only' option was used" if a test or describe is focused with .only.

Environment

  • OS: Ubuntu 24
  • deno version: 2.6.8 (stable, release, x86_64-unknown-linux-gnu) v8 14.5.201.2-rusty, typescript 5.9.2
  • std version: 1.0.17

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions