Skip to content

t.notThrows() gives no info on thrown error in case an error is thrown #1150

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

Closed
justin-calleja opened this issue Dec 9, 2016 · 2 comments · Fixed by singapore/gl-got#20
Closed
Labels
bug current functionality does not work as desired help wanted

Comments

@justin-calleja
Copy link

Description

I have yet to make a test which uses t.notThrows() pass. Is it by design to not get any info on the thrown error when t.notThrows() actually errors out? All I get is:

Got unwanted exception..

I would like to see the stack trace.

Currently, I'm expecting the code to fail with a SequelizeUniqueConstraintError: Validation error error. But since I'm not seeing anything other than Got unwanted exception.., I cannot verify this. Later on, after fixing this, if the test fails again, I would like to see the stack trace to see if it's still because of the constraint violation.

Test Source

  let [transaction, onSuccess] = await adapter.setupTransaction();
  // fails with "Got unwanted exception..". 
  await t.notThrows(Promise.all(G.deltas.map(delta => {
    return adapter.addContentObjectDelta(G.co1.getContentObjectId(), delta, {}, { transaction });
  })));
  await onSuccess();

Error Message & Stack Trace

AssertionError: Got unwanted exception..

Config

Copy the relevant section from package.json:

{
  "ava": {
    "require": [
      "babel-register",
      "babel-polyfill"
    ],
    "babel": "inherit",
    "files": [
      "test/**/*.test.js"
    ],
    "failFast": true
  },
}

Command-Line Arguments

ava --serial

--verbose does not help.

Environment

Tell us which operating system you are using, as well as which versions of Node.js, npm, and AVA. Run the following to get it quickly:

Node.js v6.3.1
darwin 15.4.0
ava: 0.17.0
npm: 3.10.3
@sindresorhus sindresorhus added bug current functionality does not work as desired help wanted labels Dec 9, 2016
@sindresorhus
Copy link
Member

Yes, that's pretty bad UX. For this assertion we're using the built-in assert module, which obviously isn't very good. We plan on rewriting the throws/notThrows assertions: #1047

@justin-calleja
Copy link
Author

Ok thanks @sindresorhus

novemberborn added a commit that referenced this issue Mar 10, 2017
This is especially useful for `t.notThrows()`, which includes the
thrown exception as the `actual` value for the assertion error.

Fixes #1150.
novemberborn added a commit that referenced this issue Mar 10, 2017
This is especially useful for `t.notThrows()`, which includes the
thrown exception as the `actual` value for the assertion error.

Fixes #1150.
novemberborn added a commit that referenced this issue Mar 13, 2017
This is especially useful for `t.notThrows()`, which includes the
thrown exception as the `actual` value for the assertion error.

Fixes #1150.
sindresorhus pushed a commit that referenced this issue Mar 14, 2017
This is especially useful for `t.notThrows()`, which includes the
thrown exception as the `actual` value for the assertion error.

Fixes #1150.
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

Successfully merging a pull request may close this issue.

2 participants