Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

angular.mock.$ExceptionHandlerProvider Provide mode logAndRethrow #10540

Closed
DavidSouther opened this issue Dec 21, 2014 · 8 comments
Closed

angular.mock.$ExceptionHandlerProvider Provide mode logAndRethrow #10540

DavidSouther opened this issue Dec 21, 2014 · 8 comments

Comments

@DavidSouther
Copy link
Contributor

https://github.com/angular/angular.js/blob/master/src/ngMock/angular-mocks.js#L253

Currently, test exceptions can either log or rethrow. There are cases where the throw behavior is expected by the implementation, but it would also be nice to have a log available. In these situations, a logAndThrow behavior would ease having two different code flows.

@petebacondarwin
Copy link
Contributor

You can easily achieve this via a decorator: http://plnkr.co/edit/OORm4yDYh2Gx1QoEvQt8

@caitp
Copy link
Contributor

caitp commented Dec 22, 2014

Actually, I think this would be good to have. It's ngMock so code size doesn't really matter, and there are a number of places where it's useful in core tests and worked around really awkwardly

@petebacondarwin
Copy link
Contributor

Oh right! I didn't notice that it was angular-mocks. Fine by me.

This is an easy first PR if anyone is interested. Just add a new option to the mode and provide suitable tests (https://github.com/angular/angular.js/blob/master/test/ngMock/angular-mocksSpec.js#L589) and documentation (https://github.com/angular/angular.js/blob/master/src/ngMock/angular-mocks.js#L246).

@DavidSouther
Copy link
Contributor Author

I'll take a shot at it :)

On Mon Dec 22 2014 at 4:54:39 AM Pete Bacon Darwin notifications@github.com
wrote:

Oh right! I didn't notice that it was angular-mocks. Fine by me.

This is an easy first PR if anyone is interested. Just add a new option to
the mode and provide suitable tests (
https://github.com/angular/angular.js/blob/master/test/ngMock/angular-mocksSpec.js#L589)
and documentation (
https://github.com/angular/angular.js/blob/master/src/ngMock/angular-mocks.js#L246
).


Reply to this email directly or view it on GitHub
#10540 (comment)
.

@caitp caitp reopened this Dec 22, 2014
@petebacondarwin
Copy link
Contributor

@DavidSouther - Great!

Please make sure that you have signed the CLA, associated it with your Github username and that your commit messages match our requirements.

Get in touch if you need any help.

@DavidSouther
Copy link
Contributor Author

Uh... none of these module(function($exceptionHandlerProvider){}) tests are actually running.

@DavidSouther
Copy link
Contributor Author

The module() calls did not have a corresponding inject(), so no assertions were executed. #10563 fixes that.

@DavidSouther
Copy link
Contributor Author

For a larger conversation, does it make sense to combine logAndRethrow into rethrow? Personally, that was my expected behavior before reading the docs that the additional logic from $exceptionHandler in mocks would only add, not change, functionality.

petebacondarwin pushed a commit that referenced this issue Dec 23, 2014
Now the `rethrow` mode will also record a log of the error in the same
way as the `log` mode.

Closes #10540
Closes #10564
petebacondarwin pushed a commit that referenced this issue Dec 23, 2014
Now the `rethrow` mode will also record a log of the error in the same
way as the `log` mode.

Closes #10540
Closes #10564

Conflicts:
	src/ngMock/angular-mocks.js
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants