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

Karma console.log or error work differently. #2863

Closed
UniverseHan opened this issue Oct 28, 2017 · 3 comments · Fixed by #2913
Closed

Karma console.log or error work differently. #2863

UniverseHan opened this issue Oct 28, 2017 · 3 comments · Fixed by #2913

Comments

@UniverseHan
Copy link

UniverseHan commented Oct 28, 2017

When

it('should show error message in Error Object', () => {
  console.log(new Error('This should be displayed'));
});

Expected behaviour

LOG: Error: This should be displayed
    at <anonymous>:1:13
    ...
    ...

Actual behaviour

LOG: TypeError{}

Environment Details

  • Karma version (output of karma --version):
    "karma": "^1.7.1",
    "karma-chrome-launcher": "^2.2.0",
    "karma-jasmine": "^1.1.0",

  • Relevant part of your karma.config.js file

Steps to reproduce the behaviour

1. Write code like below

it('Error message should be displayed', function() {
  console.log(new Error('This should be displayed'));
});

2. run karma test

$ karma start

When you log in normal nodejs app

// shouldbe.js
console.log(new TypeError('This should be displayed'));

Got this.

TypeError: This should be displayed
    at Object.<anonymous> (/Users/haseok/workspace/karma-test/expected.js:1:75)
    at Module._compile (module.js:612:30)
    at Object.Module._extensions..js (module.js:623:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)
    at Function.Module._load (module.js:486:3)
    at Function.Module.runMain (module.js:653:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3
@EzraBrooks
Copy link
Collaborator

Can you clarify why your "Actual behavior" section is blank? Does it not log the message at all?

@UniverseHan
Copy link
Author

UniverseHan commented Dec 20, 2017

@EzraBrooks I have updated actual behaviour.

I think it caused by That karma use JSON.stringify in console.log wraper function. JSON.stringify(new Error('...')) does not display message in Error.

this issue is same as #2854

@macjohnny
Copy link
Contributor

@UniverseHan can you retry with 2.0.0? maybe this was resolved with #2712 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants