question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`includeConsoleLog: true` doesn't report console output for tests

See original GitHub issue

Setup: Package.json

  "devDependencies": {
    "stuff": "stuff",
    "jest": "23.3.0",
    "jest-html-reporter": "^2.4.2"
  },
"jest": {
    "reporters": [
      "default",
      [
        "./node_modules/jest-html-reporter",
        {
          "pageTitle": "Test Report",
          "includeFailureMsg": true,
          "includeConsoleLog": true,
          "outputPath": "report/index.html"
        }
      ]
    ]
  }

Console output:

  console.log apiAgent.js:17
    Requesting: GET to: /api/cs/v2/resolver?text=Butt%20pain;%20can%E2%80%9A%C3%84%C3%B4t%20lie%20down
(this is a passing test)

  console.log apiAgent.js:17
    Requesting: GET to: /api/cs/v2/resolver?text=neck
(this is a failing test)

  console.log apiAgent.js:27
    Receive body: <html><head><title>Apache Tomcat/7.0.84 - Error report</title><style><!-

The html output only shows:


Test GET endpoint | Test passing one:  | passed in 0.115s
-- | -- | --
Test GET endpoint | Test failing one: neckError: expect(received).toBe(expected) // Object.is equality

No mention of logs on the output

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Domiiicommented, Feb 18, 2019

Same issue here.

Jest will not pass on logs made in the test specs to the reporter.

Uhm… I just want to see all console output related to a test suit. So I guess getting basic console.log output is not possible?

Debugging jest tests has been a mess from the start. Because of it’s “(pseudo-)multi-threaded nature”, console.log calls appear in confusing order and sometimes get swallowed whole. I was hoping that this plugin would sort the corresponding log calls to the corresponding tests, but I guess that would not be easily achievable. I guess it is time for a proper jest logging tool (Googling that only yields the problems with console.log)… 😕

1reaction
Benoit-Vasseurcommented, Feb 1, 2019

Ooh. Well yes the console.log is in the test file 😕.

Do you know a way to be able to have those console.log pass to the reporter (those made in spec files) ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Console.log statements output nothing at all in Jest
Run console.debug('Message here', yourValueHere) inside test function and it should show in the console output when running test script. You can verify if ......
Read more >
How to view log output while tests are running in VS 2019 ...
My goal is to view log output in Visual Studio 2019 Pro, for all unit tests, while the tests are running. I tried...
Read more >
JavaScript Console.log() Example – How to Print to the ...
Just open the console, Ctrl+Shift+K or F12 , and in the top right you will see a button that says "Switch to multi-line...
Read more >
Console | Node.js v19.3.0 Documentation
A Console class with methods such as console.log() , console.error() , and console.warn() that can be used to write to any Node.js stream....
Read more >
Capturing Output > xUnit.net
Capturing output in unit tests; Capturing output in extensibility classes. If you used xUnit.net 1.x, you may have previously been writing output to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found