Skip to content

Improve asserting error messages when deepEqual is false and array includes other props #851

@mattkrick

Description

@mattkrick

Description

When an array has a property, it never shows up in the console & that prop gets lost when the array gets stringified. That's fine, it's been this way in the JS world forever, but it makes it really hard to debug. I'm not sure about the best way to handle this, but I think if we got the same message that we get when we run AVA's internal tests, I'd be pretty happy (see example below).

Test Source

// in AVA's assert.js
    t.doesNotThrow(function () {
        var first = [1,2,3];
        first.foo = 'first';
        assert.deepEqual(first, [1, 2, 3]);
    });

Error Message & Stack Trace

// in my tests
  t.deepEqual(first, [1, 2, 3])
              |                
              [1,2,3]          

      Test.fn (normalizeResponse-test.js:90:5)


// in AVA's internal testing
test/assert.js ...................................... 56/57
  .deepEqual()
  not ok expected to not throw
    at:
      line: 145
      column: 10
      file: test/assert.js
    stack: |
      test/assert.js:145:10
      test/assert.js:142:4
      Object.<anonymous> (test/assert.js:122:1)
    name: AssertionError
    actual:
      - 1
      - 2
      - 3
    expected:
      - 1
      - 2
      - 3
    operator: ===
    generatedMessage: true
    message: 'AssertionError: [ 1, 2, 3, foo: ''first'' ] === [ 1, 2, 3 ]' //I want this!
    source: |
      assert.deepEqual(first, [1, 2, 3]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions