17

I'm using grunt-contrib-jasmine to run my javascript specs. How do I write debug output to the console when running specs i.e. how do I get

console.log("something");

to show output in the console? I do find that I can get output by running:

 $ grunt jasmine --verbose

But this prints a lot of information that I'm not interested in. How can I just see the output from console.log ?

opsb
  • 29,325
  • 19
  • 89
  • 99

3 Answers3

38

Use console.info instead of console.log

badsyntax
  • 9,394
  • 3
  • 49
  • 67
  • 3
    Don't forget `console.debug()`, `console.warn()`, and `console.error()` – steveluscher Jul 08 '13 at 17:44
  • 1
    Why? Is `console.log` more for random logging that the test filters out purposely? – Jess Sep 18 '13 at 14:29
  • I'm afraid I'm getting the same result as @sten-muchow. None of the console output (log, info or error) is appearing. – Typhlosaurus Sep 04 '14 at 14:30
  • 1
    Ah, got it. Turns out one needs the --debug grunt option rather than --verbose. console.log, info and error all appear although there's no indication of which is which. – Typhlosaurus Sep 04 '14 at 14:45
2

Not a solution but a work around (sort of). Put in a expect("something").toBe(null); This will make jasmine to write out an error message like: Expected 'something' to be null. This way you can peek into objects (expect(element).toBe(null);)

Falko
  • 17,076
  • 13
  • 60
  • 105
Don Kartacs
  • 396
  • 3
  • 8
0

You can also use dump(variable) or console.log(variable). Source is the excellent Year of Moo.

Danger14
  • 760
  • 2
  • 12
  • 33