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

"includeConsoleLog": true is not working when testMatch or testPathIgnorePatterns is added #61

Closed
prashanth-sams opened this issue Feb 17, 2019 · 9 comments
Assignees
Labels

Comments

@prashanth-sams
Copy link

prashanth-sams commented Feb 17, 2019

the console logs are not generated in the html file, when I mention the spec location.

{
  "verbose":true,
  "testMatch":["<rootDir>/**/*.spec.js"],
  "testPathIgnorePatterns": ["/node_modules/", "<rootDir>/src/"],
  "reporters": [
    "default", ["./node_modules/jest-html-reporter", {
        "pageTitle": "Test Report",
        "outputPath": "reports/test-report.html",
        "includeFailureMsg": true,
        "includeConsoleLog": true
    }]
  ]
}

jest --config=jest.config.json

or

{
  "reporters": [
    "default", ["./node_modules/jest-html-reporter", {
        "pageTitle": "Test Report",
        "outputPath": "reports/test-report.html",
        "includeFailureMsg": true,
        "includeConsoleLog": true
    }]
  ]
}

jest path/ --config=jest.config.json

Output:
image

Please clone and run tests from this repo for debugging: https://github.com/prashanth-sams/api-automation-frisby-typescript

@prashanth-sams
Copy link
Author

@Hargne would be great if you see what's wrong 💯from the above test repo

@Hargne Hargne self-assigned this Mar 7, 2019
@Hargne
Copy link
Owner

Hargne commented Mar 7, 2019

Hi,
Sorry for the late response (I am currently abroad with crappy-to-none internet connectivity)!

Just to rule it out: will the console.logs be outputted if you don't include testMatch or testPathIgnorePatterns?

@Hargne
Copy link
Owner

Hargne commented Mar 7, 2019

I just ran some tests and it seems like it is actually the verbose: true that is causing this. The logs will appear if verbose is set to false or not present at all.
There is more information about this matter in this stack overflow thread

@prashanth-sams
Copy link
Author

thanks @Hargne; let me give a try.

Just to rule it out: will the console.logs be outputted if you don't include testMatch or testPathIgnorePatterns?

  • Yes, it does work when I skip these

@Hargne
Copy link
Owner

Hargne commented Mar 7, 2019

It should work as intended as long as you remove the verbose: true from your config (see my previous post)

@jbournonville
Copy link

Hello,
I have the same problem and even without verbose: true, I can't get console logs in the report.

module.exports = {
  testEnvironment: 'node',
  setupTestFrameworkScriptFile: './test/setupTests.js',
  reporters: [
    'default',
    [
      './node_modules/jest-html-reporter',
      {
        pageTitle: 'Test Report',
        outputPath: './test/testReport/report.html',
        includeFailureMsg: true,
        includeConsoleLog: true
      }
    ]
  ]
}

@Hargne
Copy link
Owner

Hargne commented Mar 20, 2019

@jbournonville is it possible to post one of the test specs that includes a console log?

@alexey-temnikov
Copy link

Have same issue, but for me it stopped working after upgrade to jest@24.7.1 (works fine with 24.5.0).
Interesting thing - regular downgrade by installing other version doesn't help - full revert of package-lock.json works though.

@Hargne
Copy link
Owner

Hargne commented Nov 5, 2019

Hi again,

In the latest release (https://github.com/Hargne/jest-html-reporter/releases/tag/2.7.0) I was able to manually catch all the console.logs per test and then output it to each test suite.

It should be noted that in order for this to work, you need to assign jest-html-reporter as a custom reporter in Jest via the "reporters" option (https://github.com/Hargne/jest-html-reporter/wiki/installation-and-usage#usage)
And you will probably also need to run jest together with the --verbose=false setting.

@Hargne Hargne closed this as completed Nov 5, 2019
@Hargne Hargne added bug and removed waiting reponse labels Nov 5, 2019
ptabor pushed a commit to ptabor/jest-html-reporter that referenced this issue Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants