©
Dieses Dokument verwendetPHP-Handbuch für chinesische WebsitesFreigeben
Mock implementation of$exceptionHandler
that rethrows or logs errors passed into it. See $exceptionHandlerProvider for configuration information.
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]]);});});});