You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
The current version of ngMock is breaking, generating meaningless error messages for tests when used with some Webkit-based browsers, although it is working fine in Chrome. For example:
1'use strict';2describe('failure in ng-mocks',function(){3beforeEach(inject(function($compile,$rootScope){4$compile(5'<div ng-include="\'nofilehere\'"></div>'6)($rootScope);7$rootScope.$digest();8}));9it('displayed by example',function(){10console.log('hello, world');11});12});
The test properly fails at line 5 because "nofilehere" does not exist and has not been inserted into the template cache. We get a very meaningful message when driving this with karma under Chrome (and it worked until recently on most browsers):
Error: Unexpected request: GET nofilehere
(stack trace)
At this time, however, PhantomJS and Chrome instead give the following:
TypeError: Attempted to assign to readonly property.
at workFn (/Users/werdna/errors/app/bower_components/angular-mocks/angular-mocks.js:2122)
This occurs because the error is at one time caught at line 2122 in the following angular-mocks code:
2116for(vari=0,ii=blockFns.length;i<ii;i++){2117try{2118/* jshint -W040 *//* Jasmine explicitly provides a `this` object when calling functions */2119injector.invoke(blockFns[i]||angular.noop,this);2120/* jshint +W040 */2121}catch(e){2122if(e.stack&&errorForStack)e.stack+='\n'+errorForStack.stack;2123throwe;2124}finally{2125errorForStack=null;2126}2127}
and some recent versions of Webkit Error messages now have read-only 'stack' properties. (Both configurable and writable are false.) Thus, line 2122 fails because e.stack is unwritable, and the new TypeError is thrown, losing the old stack when the TypeError is created.
Unfortunately, I couldn't think of any other way to rethrow an Error instance with a modified stack string, and was unable to come up with a meaningful pull request.
Unfortunately, this makes Unit testing difficult, and whatever benefit derives from inserting the errorForStack message is lost to me now.
Any thoughts?
The text was updated successfully, but these errors were encountered:
The current version of ngMock is breaking, generating meaningless error messages for tests when used with some Webkit-based browsers, although it is working fine in Chrome. For example:
The test properly fails at line 5 because "nofilehere" does not exist and has not been inserted into the template cache. We get a very meaningful message when driving this with karma under Chrome (and it worked until recently on most browsers):
At this time, however, PhantomJS and Chrome instead give the following:
This occurs because the error is at one time caught at line 2122 in the following angular-mocks code:
and some recent versions of Webkit Error messages now have read-only 'stack' properties. (Both configurable and writable are false.) Thus, line 2122 fails because e.stack is unwritable, and the new TypeError is thrown, losing the old stack when the TypeError is created.
Unfortunately, I couldn't think of any other way to rethrow an Error instance with a modified stack string, and was unable to come up with a meaningful pull request.
Unfortunately, this makes Unit testing difficult, and whatever benefit derives from inserting the errorForStack message is lost to me now.
Any thoughts?
The text was updated successfully, but these errors were encountered: