avajs/ava

Show relevant parts of the object/array for t.true/t.false assertion output #1205

vadimdemedes posted onGitHub

Note, this issue is related only to #1154.

Given this assertion:

t.true(arr[56]);

if the size of arr is (for example) 100, AVA will output the whole array without pointing to the specific item that caused an assertion error. We should show only the relevant parts of the array/object to identify the cause of an issue quicker. Plus, we really don't want to trash user's terminal.


@vadimdemedes thanks for pointing it out. I actually faced this thing last night and was thinking to open an issue.

posted by yatharthk about 8 years ago

My suggestion in #1204 is to show the type of arr but nothing else.

posted by novemberborn about 8 years ago

Guys, do you have any update regarding this request?

I'm facing the same issue. If I use t.is(resetBehaviour.calledOnce, false); it outputs this:

51:     wrapper.unmount();
   52:     t.is(resetBehaviour.calledOnce, false);
   53: });

  Difference:

  - true
  + false

  Test.is (src/common/components/App/App.test.js:52:7)
  processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
  processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)

But if i use t.false(resetBehaviour.calledOnce) it returns this huge output:

51:     wrapper.unmount();
   52:     t.false(resetBehaviour.calledOnce);
   53: });

  Value is not `false`:

  true

  resetBehaviour.calledOnce
  => true

  resetBehaviour
  => Function proxy {
    args: [
      [],
    ],
    callCount: 1,
    callIds: [
      4,
    ],
    called: true,
    calledOnce: true,
    calledThrice: false,
    calledTwice: false,
    displayName: 'spy',
    errorsWithCallStack: [
      Error {
        message: '',
      },
    ],
    exceptions: [
      undefined,
    ],
    firstCall: {
      args: [],
      callId: 4,
      callback: undefined,
      errorWithCallStack: Error {
        message: '',
      },
      exception: undefined,
      lastArg: undefined,
      proxy: [Circular],
      returnValue: undefined,
      thisValue: {
        resetBehaviour: [Circular],
      },
    },
    id: 'spy#3',
    instantiateFake: Function create {},
    isSinonProxy: true,
    lastCall: {
      args: [],
      callId: 4,
      callback: undefined,
      errorWithCallStack: Error {
        message: '',
      },
      exception: undefined,
      lastArg: undefined,
      proxy: [Circular],
      returnValue: undefined,
      thisValue: {
        resetBehaviour: [Circular],
      },
    },
    notCalled: false,
    returnValues: [
      undefined,
    ],
    secondCall: null,
    thirdCall: null,
    thisValues: [
      {
        resetBehaviour: [Circular],
      },
    ],
    toString: Function toString {},
  }

  Test.t [as fn] (src/common/components/App/App.test.js:52:5)
  processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
  processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)

I'm using sinon spies and the log output is completely uselesss in this case.

posted by leandrooriente about 6 years ago

@issuehunt has funded $60.00 to this issue.


posted by IssueHuntBot almost 6 years ago

FWIW, AVA no longer prints output like this, though it's supported through @ava/babel. I'm going to close this issue since I don't think we'll make any progress on this one way or the other.

posted by novemberborn almost 5 years ago

Fund this Issue

$60.00
Funded

Pull requests

Recent activities

issuehunt funded 60.00 for avajs/ava# 1205
almost 6 years ago