How to test if console.error fired in jasmin
up vote
0
down vote
favorite
I have an error handling service that prints console.error statements that differ depending on what's passed in (ex. http error vs non-http error).
Is there any way to test for the existance of console.error statements that are outputted from the service?
angular jasmine
add a comment |
up vote
0
down vote
favorite
I have an error handling service that prints console.error statements that differ depending on what's passed in (ex. http error vs non-http error).
Is there any way to test for the existance of console.error statements that are outputted from the service?
angular jasmine
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have an error handling service that prints console.error statements that differ depending on what's passed in (ex. http error vs non-http error).
Is there any way to test for the existance of console.error statements that are outputted from the service?
angular jasmine
I have an error handling service that prints console.error statements that differ depending on what's passed in (ex. http error vs non-http error).
Is there any way to test for the existance of console.error statements that are outputted from the service?
angular jasmine
angular jasmine
asked Nov 9 at 21:04
RandomUs1r
2,52411227
2,52411227
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
You can use spies for this:
spyOn(console, 'error');
// execute your tests
expect(console.error).toHaveBeenCalledWith("your expected message");
Got it, thanks!
– RandomUs1r
Nov 9 at 21:23
Great answer. To the point.
– jburtondev
Nov 9 at 21:37
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You can use spies for this:
spyOn(console, 'error');
// execute your tests
expect(console.error).toHaveBeenCalledWith("your expected message");
Got it, thanks!
– RandomUs1r
Nov 9 at 21:23
Great answer. To the point.
– jburtondev
Nov 9 at 21:37
add a comment |
up vote
2
down vote
accepted
You can use spies for this:
spyOn(console, 'error');
// execute your tests
expect(console.error).toHaveBeenCalledWith("your expected message");
Got it, thanks!
– RandomUs1r
Nov 9 at 21:23
Great answer. To the point.
– jburtondev
Nov 9 at 21:37
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You can use spies for this:
spyOn(console, 'error');
// execute your tests
expect(console.error).toHaveBeenCalledWith("your expected message");
You can use spies for this:
spyOn(console, 'error');
// execute your tests
expect(console.error).toHaveBeenCalledWith("your expected message");
answered Nov 9 at 21:11
user184994
10.7k11526
10.7k11526
Got it, thanks!
– RandomUs1r
Nov 9 at 21:23
Great answer. To the point.
– jburtondev
Nov 9 at 21:37
add a comment |
Got it, thanks!
– RandomUs1r
Nov 9 at 21:23
Great answer. To the point.
– jburtondev
Nov 9 at 21:37
Got it, thanks!
– RandomUs1r
Nov 9 at 21:23
Got it, thanks!
– RandomUs1r
Nov 9 at 21:23
Great answer. To the point.
– jburtondev
Nov 9 at 21:37
Great answer. To the point.
– jburtondev
Nov 9 at 21:37
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233251%2fhow-to-test-if-console-error-fired-in-jasmin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown