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

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

Closed
mattkrick opened this issue May 21, 2016 · 2 comments
Labels
enhancement new functionality

Comments

@mattkrick
Copy link
Contributor

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]);
@sindresorhus
Copy link
Member

// @twada

@novemberborn
Copy link
Member

This has been solved with magic assert and the new formatting that landed in #1341.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new functionality
Projects
None yet
Development

No branches or pull requests

3 participants