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

When assertion count is incorrect, output the expected and actual values. #102

Closed
dylang opened this issue Oct 24, 2015 · 6 comments
Closed
Labels
bug current functionality does not work as desired help wanted

Comments

@dylang
Copy link

dylang commented Oct 24, 2015

I see that the actual count is recorded, but I'm not sure how to see it when running ava.

https://github.com/sindresorhus/ava/blob/master/lib/test.js#L150-L158

❯ npm test

> [email protected] test /Users/dgreene/projects/npm-check
> xo && ava ./test


  ✖ require Assertion count does not match planned

  1 test failed

  1. require
  Error
    at Test.plan (/Users/dgreene/projects/npm-check/node_modules/ava/lib/test.js:87:19)
    at Test.<anonymous> (/Users/dgreene/projects/npm-check/test/test.js:10:7)
    at step (/Users/dgreene/projects/npm-check/test/test.js:5:273)
    at Test.fn (/Users/dgreene/projects/npm-check/test/test.js:5:99)

The above is using using master with power-assert added.

Similar output using the published version

> [email protected] test /Users/dgreene/projects/npm-check
> xo && ava ./test


  ✖ require Assertion count does not match planned

  1 test failed

  1. require
  Error
    at Test.plan (/Users/dgreene/projects/npm-check/node_modules/ava/lib/test.js:59:19)
    at Object.callee$0$0$ (/Users/dgreene/projects/npm-check/test/test.js:10:7)
    at Test.callee$0$0 [as fn] (/Users/dgreene/projects/npm-check/test/test.js:32:26)
@sindresorhus sindresorhus added the bug current functionality does not work as desired label Oct 29, 2015
@sindresorhus
Copy link
Member

Confirmed.

@dylang
Copy link
Author

dylang commented Nov 1, 2015

It seems simple to change the message in https://github.com/sindresorhus/ava/blob/04b3db5d96d6530d6b03c5f8f4c915dea16cd125/lib/test.js#L155, or would you prefer to use the stored actual and expected properties in the rederer?

@sindresorhus
Copy link
Member

The actual stored props should be used, but unsure why they're not. Maybe because we overwrite the stack in https://github.com/sindresorhus/ava/blob/04b3db5d96d6530d6b03c5f8f4c915dea16cd125/lib/test.js#L159.

@ariporad
Copy link
Contributor

Ok, @sindresorhus: Here's the problem. Actual/expected are only included when no message is provided, see here and here. So we have to include that in the error message ourself. I'll submit a PR.

@ariporad
Copy link
Contributor

Fixed in #376.

@zweicoder
Copy link

+1, would like to see this fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug current functionality does not work as desired help wanted
Projects
None yet
Development

No branches or pull requests

4 participants