Skip to content

assertObjectMatch error message diff prints arrays as objects #3472

Closed

Description

@vwkd

Describe the bug

The error message diff in assertObjectMatch prints arrays as objects.

This happens if the value has potentially nested property with an array or if the value itself is an array.

Steps to Reproduce

import { assertObjectMatch } from "https://deno.land/[email protected]/testing/asserts.ts";

Deno.test("foo", () => {
  const act = { foo: [] };

  const exp = {
    foo: [
      "bar",
    ],
  };

  assertObjectMatch(act, exp);
});

Expected behavior

    [Diff] Actual / Expected


    {
+     foo: [
+       "bar",
+     ],
-     foo: [],
    }

Actual behavior

    [Diff] Actual / Expected


    {
+     foo: {
+       "0": "bar",
+     },
-     foo: {},
    }

Environment

  • OS: macOS 12.6.6
  • deno version: deno 1.34.1
  • std version: 0.191.0

Activity

  1. added
    bug
    on Jun 30, 2023
  2. changed the title [-]`assertObjectMatch` error message prints arrays as objects[/-] [+]`assertObjectMatch` error message diff prints arrays as objects[/+] on Jun 30, 2023
  3. hasundue commented on Sep 3, 2023

    @hasundue
    Contributor

    Happened to me too.

    deno 1.36.0 (release, x86_64-unknown-linux-gnu)
    v8 11.6.189.12
    typescript 5.1.6
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions