deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

`expect().toContain()` error message doesn't show expected string

Open marvinhagemeister opened this issue 1 year ago • 0 comments
trafficstars

Describe the bug

When an expect().toContain() assertion failed we get a very generic error message:

error: AssertionError: The value doesn't contain the expected item
      throw new AssertionError("The value doesn't contain the expected item");

This makes it difficult to know what exactly went wrong.

Steps to Reproduce

import { expect } from "jsr:@std/expect";

Deno.test("foo", () => {
  expect("foobar").toContain("baz");
});

Expected behavior

Print something like Input string did not contain "baz". Not sure what to do for long strings though.

Environment

  • OS: macOS 14.4.1
  • deno version: 1.42.4
  • std version: 0.224.0

marvinhagemeister avatar Apr 29 '24 17:04 marvinhagemeister