ngMock.$exceptionHandlerProvider

  1. $exceptionHandler
  2. provider in module ngMock

Configures the mock implementation of $exceptionHandler to rethrow or to log errors passed to the $exceptionHandler.

Methods

  • mode(mode);

    Sets the logging mode.

    Parameters

    Param Type Details
    mode string

    Mode of operation, defaults to rethrow.

    • log: Sometimes it is desirable to test that an error is thrown, for this case the log
      1
      2
      3
      mode stores an array of errors in `$exceptionHandler.errors`, to allow later
      assertion of them. See <a href="/references/JavaScript-AngularJS-ngMock/ngMock%252E%2524log.html#assertEmpty">assertEmpty()</a> and
      <a href="/references/JavaScript-AngularJS-ngMock/ngMock%252E%2524log.html#reset">reset()</a>
    • rethrow: If any errors are passed to the handler in tests, it typically means that there
      1
      2
      3
      is a bug in the application or test, so this mock will make these tests fail.
      For any implementations that expect exceptions to be thrown, the `rethrow` mode
      will also maintain a log of thrown errors.
doc_AngularJS
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.