Skip to content

Conversation

@therealklanni
Copy link
Contributor

If a Promise is rejected with a string, t.throws() fails the test with "undefined undefined undefined" instead of the label of the assertion or any other identifying information, leaving the dev writing the tests unable to easily pinpoint which test has just failed.

Reproduce by writing a t.throws() assertion for a Promise that rejects simply using a string and have a RegExp validation rule.

Before:

  1 failed

  1. rejects
  undefined undefined undefined
  AssertionError: undefined undefined undefined

After:

  1 failed

  1. rejects
  Invalid due date 19791224T245051Z
  AssertionError: Invalid due date 19791224T245051Z

@sindresorhus
Copy link
Member

Can you add a test? So we can ensure it doesn't regress.

Should be added around here: https://github.com/sindresorhus/ava/blob/7b764ea3be2d0ad1d894d015feac8b38b7e071ce/test/promise.js#L179

@therealklanni
Copy link
Contributor Author

Certainly

@therealklanni
Copy link
Contributor Author

Oh, I added it in assert.js before I saw your edit.

lib/assert.js Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think testing if fnErr instanceof Error would be better here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I'll update.

@sindresorhus sindresorhus changed the title Bugfix: throws method doesn't output failure reason Fix t.throws/doesNotThrow not outputting failure reason Jan 10, 2016
@sindresorhus
Copy link
Member

Thank you @therealklanni :)

@vadimdemedes
Copy link
Contributor

Thank you!

@therealklanni
Copy link
Contributor Author

Np, guys, thanks for this great tool! 🤘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants