Skip to content

describe.skip does not skip assertions in block #6233

Closed
@dandv

Description

@dandv

I expect that skipped describe blocks don't run any code inside, and especially not assertions.

Steps to Reproduce

  1. Create denobug.test.ts
import { describe, it } from '@std/testing/bdd';
import { assertExists } from 'jsr:@std/assert';

let skipTestingThisVariable: string;

describe.skip('skip everything in here', () => {
  assertExists(skipTestingThisVariable);  // <-- this line should be skipped
  it('should work', () => {
    assertExists(true);
  });
});
  1. Run deno test denobug.test.ts
Uncaught error from ./denobug.test.ts FAILED

 ERRORS 

./denobug.test.ts (uncaught error)
error: (in promise) AssertionError: Expected actual: "undefined" to not be null or undefined.
    throw new AssertionError(msg);
          ^
    at assertExists (https://jsr.io/@std/assert/1.0.8/exists.ts:29:11)
    at file:///~/deno/denobug.test.ts:7:3
    at new TestSuiteInternal (https://jsr.io/@std/testing/1.0.5/_test_suite.ts:91:23)
    at describe (https://jsr.io/@std/testing/1.0.5/bdd.ts:1111:22)
    at Function.describeIgnore [as ignore] (https://jsr.io/@std/testing/1.0.5/bdd.ts:1176:10)
    at Function.describeSkip [as skip] (https://jsr.io/@std/testing/1.0.5/bdd.ts:1208:19)
    at file:///~/deno/denobug.test.ts:6:10
This error was not caught from a test and caused the test runner to fail on the referenced module.
It most likely originated from a dangling promise, event/timeout handler or top-level code.

 FAILURES 

./denobug.test.ts (uncaught error)

FAILED | 0 passed | 1 failed (0ms)

error: Test failed

Expected behavior

The test should be ignored. If the assertExists(skipTestingThisVariable); is moved into the it, then it's correctly ignored

import { describe, it } from '@std/testing/bdd';
import { assertExists } from 'jsr:@std/assert';

let skipTestingThisVariable: string;

describe.skip('skip everything in here', () => {
  it('should work', () => {
    assertExists(skipTestingThisVariable);  // test is ignored now
    assertExists(true);
  });
});

Environment

  • deno version: 2.1.2
  • std version: "jsr:@std/expect@*": "1.0.8"

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