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

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

Closed
marvinhagemeister opened this issue Apr 29, 2024 · 3 comments
Closed
Labels
bug Something isn't working expect PR welcome A pull request for this issue would be welcome

Comments

@marvinhagemeister
Copy link
Contributor

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 marvinhagemeister added bug Something isn't working needs triage labels Apr 29, 2024
@iuioiua iuioiua added expect PR welcome A pull request for this issue would be welcome and removed needs triage labels Apr 29, 2024
@JakeAve
Copy link
Contributor

JakeAve commented May 16, 2024

I've never used toContainEqual but it looks like we could do the same thing there. Should I include that in the PR?

@marvinhagemeister
Copy link
Contributor Author

Good idea, makes sense to add this to toContainEqual too

@kt3k
Copy link
Member

kt3k commented May 17, 2024

fixed in #4750

@kt3k kt3k closed this as completed May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working expect PR welcome A pull request for this issue would be welcome
Projects
None yet
Development

No branches or pull requests

4 participants