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

assert: provide extra context in case of failed error validation checks #28263

Closed

Commits on Jun 15, 2019

  1. assert: improve class instance errors

    This improves `assert.throws()` and `assert.rejects()` in case error
    classes are used as validation for the expected error.
    
    In case of a failure it will now throw an `AssertionError` instead
    of the received error if the check fails. That error has the received
    error as actual property and the expected property is set to the
    expected error class.
    
    The error message should help users to identify the problem faster
    than before by providing extra context what went wrong.
    BridgeAR committed Jun 15, 2019
    Copy the full SHA
    75e5ba1 View commit details
    Browse the repository at this point in the history
  2. assert: fix generatedMessage property

    This makes sure the `generatedMessage` property is always set as
    expected. This was not the case some `assert.throws` and
    `assert.rejects` calls.
    BridgeAR committed Jun 15, 2019
    Copy the full SHA
    f90cfca View commit details
    Browse the repository at this point in the history
  3. assert: wrap validation function errors

    This makes sure that validation function used by `assert.throws` and
    `assert.rejects` always throw validatin errors instead of rethrowing
    the received error.
    
    That should improve the debugging experience for developers since
    they have a better context where the error is coming from and they
    also get to know what triggered it.
    BridgeAR committed Jun 15, 2019
    Copy the full SHA
    4d29fd1 View commit details
    Browse the repository at this point in the history
  4. assert: DRY .throws code

    This refactors some code for less duplication.
    BridgeAR committed Jun 15, 2019
    Copy the full SHA
    1563d9d View commit details
    Browse the repository at this point in the history
  5. assert: add more information to AssertionErrors

    This adds information about the actual thrown error to the
    AssertionError's message property.
    
    It also improves the logged error instances error name by using the
    constructors name, if available.
    BridgeAR committed Jun 15, 2019
    Copy the full SHA
    9d7d103 View commit details
    Browse the repository at this point in the history
  6. assert: special handle identical error names in instance checks

    This makes sure that using `assert.throws()` or `assert.rejects()`
    in combination with Error classes log appropriate error messages
    in case the expected and received constructor name are identical
    but not part of the same prototype chain.
    BridgeAR committed Jun 15, 2019
    Copy the full SHA
    adb44d3 View commit details
    Browse the repository at this point in the history

Commits on Jun 17, 2019

  1. doc: update assert.throws() examples

    This updates two outdated examples to the current implementation.
    BridgeAR committed Jun 17, 2019
    Copy the full SHA
    e096890 View commit details
    Browse the repository at this point in the history
  2. doc: update assert.throws example

    This makes sure the current validation function example reflects the
    current implementation.
    BridgeAR committed Jun 17, 2019
    Copy the full SHA
    fa0f3f1 View commit details
    Browse the repository at this point in the history

Commits on Jun 20, 2019

  1. doc: make AssertionError a link

    This makes sure that `AssertionError` links to the correct place in
    the assert documentation.
    BridgeAR committed Jun 20, 2019
    Copy the full SHA
    683e311 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    9832d3d View commit details
    Browse the repository at this point in the history