Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

describe and Deno.test() don't mix #6347

Closed
dandv opened this issue Jan 15, 2025 · 1 comment
Closed

describe and Deno.test() don't mix #6347

dandv opened this issue Jan 15, 2025 · 1 comment

Comments

@dandv
Copy link
Contributor

dandv commented Jan 15, 2025

Describe the bug

Thinking test is an eventually alias for Deno.test(), I didn't pay much attention when I left Deno.test()s inside a describe during a refactoring. But the result is that the describe succeeds even if a Deno.test() fails.

Steps to Reproduce

main_test.ts:

import { describe } from '@std/testing/bdd';
import { assertEquals } from "@std/assert";

describe('addition', () => {
  Deno.test(function addTest1() {
    assertEquals(2 + 3, 6);
  });

  Deno.test(function addTest2() {
    assertEquals(2 + 2, 4);
  });
});
$ deno test
Check file:///home/dandv/deno-bugs/main_test.ts
running 3 tests from ./main_test.ts
addTest1 ... FAILED (7ms)
addTest2 ... ok (0ms)
addition ... ok (0ms)

 ERRORS

addTest1 => ./main_test.ts:5:8
error: AssertionError: Values are not equal.


    [Diff] Actual / Expected


-   5
+   6

  throw new AssertionError(message);
        ^
    at assertEquals (https://jsr.io/@std/assert/1.0.10/equals.ts:64:9)
    at addTest1 (file:///home/dandv/deno-bugs/main_test.ts:6:5)

 FAILURES

addTest1 => ./main_test.ts:5:8

FAILED | 2 passed | 1 failed (14ms)

error: Test failed

Expected behavior

Same as if replacing Deno.test with test. Now,

  • running 3 tests from ./main_test.ts is incorrect
  • addition should not be ok
  • FAILED | 2 passed | 1 failed - incorrect

Environment

  • OS: Fedora Linux 38
  • deno version: 2.1.4
  • std version: @std/testing@^1.0.9
@dandv dandv added bug Something isn't working needs triage labels Jan 15, 2025
@kt3k kt3k removed bug Something isn't working needs triage labels Jan 21, 2025
@kt3k
Copy link
Member

kt3k commented Jan 21, 2025

These 2 sets of test runners are not supposed to work together in nested way like the above. Please use either Deno.test or describe at a time. (The mixed usage with non nested way should be fine though)

@kt3k kt3k closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants