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

fix(test): Test errors aren't being propagated in gulp test.unit.js (possibly other tasks) #2570

Closed
jeffbcross opened this issue Jun 16, 2015 · 6 comments
Labels
area: testing Issues related to Angular testing features, such as TestBed type: bug/fix

Comments

@jeffbcross
Copy link
Contributor

See this job for example: https://travis-ci.org/angular/angular/jobs/67065781

If I debug the code, I see the actual error being caught and re-thrown through InstantiationError is "Cannot read property 'fromArray' of undefined", an error I immediately know how to fix.

I tinkered with it, and it looks like the problem is when calling super() in subclass of BaseException without a message, any message that would be added after calling super gets lost. If I pass an arbitrary string to super here: https://github.com/angular/angular/blob/master/modules/angular2/src/di/exceptions.ts#L40 then a better message is displayed. This may be an issue in the underlying engine, and seems related to microsoft/TypeScript#1168

CC: @alexeagle who has looked at this TS issue before.

@jeffbcross jeffbcross added type: bug/fix area: testing Issues related to Angular testing features, such as TestBed P3: important labels Jun 16, 2015
@vicb
Copy link
Contributor

vicb commented Jun 16, 2015

Could this help ? #2102 (not sure if it has been merged and if not why).

👍 to fix this, very annoying

@jeffbcross
Copy link
Contributor Author

The version of TypeScript we're using is @alexeagle's fork which declares Error as a class, which should be supported according to microsoft/TypeScript#1168. Though in that issue, others have issues with extending the class.

@jeffbcross
Copy link
Contributor Author

One potential fix is to require that every subclass of Error be constructed with an already-formatted message, instead of allowing construction of the message inside the constructor after super().

jeffbcross added a commit to jeffbcross/angular that referenced this issue Jun 17, 2015
For subclasses of Error, initializing classes without providing a 
message to super() would cause any messages to be suppressed from
logged errors. This fix provides an initial message to super().

Fixes angular#2570
@jeffbcross
Copy link
Contributor Author

I opened a PR with a unit test for JS. #2580

I just call super with the same logic from further down in the constructor where the initial message is generated. This approach may be flawed, in that if the provided function would ever output an empty string (or undefined), the eventual message may still not be logged.

jeffbcross added a commit to jeffbcross/angular that referenced this issue Jun 17, 2015
For subclasses of Error, initializing classes without providing a 
message to super() would cause any messages to be suppressed from
logged errors. This fix provides an initial message to super().

Fixes angular#2570
jeffbcross added a commit to jeffbcross/angular that referenced this issue Jun 18, 2015
The stack property of BaseException was previously being set in
the constructor based on the provided message, but subclasses 
of BaseException would change the message after constructing the 
error. This change implements stack as a getter of BaseException,
deferring the creation of the stack until it is asked for.

Fixes angular#2570
@jeffbcross
Copy link
Contributor Author

Closing issue in favor of #2606

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: testing Issues related to Angular testing features, such as TestBed type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants