Spec-Zone.ru › Angular.js 1.6

Улучшить эту документацию Посмотреть исходный код $exceptionHandler

  1. $exceptionHandlerProvider
  2. сервис в модуле ngMock

Обзор

Мок-реализация $exceptionHandler, которая перебрасывает или регистрирует ошибки, переданные ей. См. $exceptionHandlerProvider для получения информации о конфигурации.

describe('$exceptionHandlerProvider', function() {

  it('should capture log messages and exceptions', function() {

    module(function($exceptionHandlerProvider) {
      $exceptionHandlerProvider.mode('log');
    });

    inject(function($log, $exceptionHandler, $timeout) {
      $timeout(function() { $log.log(1); });
      $timeout(function() { $log.log(2); throw 'banana peel'; });
      $timeout(function() { $log.log(3); });
      expect($exceptionHandler.errors).toEqual([]);
      expect($log.assertEmpty());
      $timeout.flush();
      expect($exceptionHandler.errors).toEqual(['banana peel']);
      expect($log.log.logs).toEqual([[1], [2], [3]]);
    });
  });
});

© 2010–2018 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://code.angularjs.org/1.6.9/docs/api/ngMock/service/$exceptionHandler

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API