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.arrayContaining + expect.objectContaining broken #6243

Closed
dandv opened this issue Dec 7, 2024 · 1 comment · Fixed by #6271
Closed

expect.arrayContaining + expect.objectContaining broken #6243

dandv opened this issue Dec 7, 2024 · 1 comment · Fixed by #6271
Labels
bug Something isn't working needs triage

Comments

@dandv
Copy link
Contributor

dandv commented Dec 7, 2024

A common use case in testing is making sure an array contains an object with a given shape. This blog post discusses it. The code from the blog post works with Jet but fails with @std/expect. Example (with additional test) below.

Steps to Reproduce

import { test } from '@std/testing/bdd';
import { expect } from '@std/expect';

const a = [
  { foo: 'bar' },
  { foo: 'baz' },
];

test('matchObject on array', () => {
  expect(a).toEqual(expect.arrayContaining([
    expect.objectContaining({ foo: 'bar' }),
  ]));
});

const state = [
  { type: "START", data: "foo" },
  { type: "START", data: "baz" },
  { type: "END", data: "foo" },
];

test("test from blog post", () => {
  expect(state).toEqual(
    // 1
    expect.arrayContaining([
      // 2
      expect.objectContaining({
        // 3
        type: "END", // 4
      }),
    ])
  );
});

Expected behavior

CodeSanbox

Environment

  • deno version: 2.1.3
  • @std/expect version: 1.0.9
@eryue0220
Copy link
Contributor

Thank you for your feedback, I'll check this case later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants