Webstorm console.log additional unwanted annotations

Webstorm (and IDEA is acting the same) adds extra information to each console.log.  For example I am getting:

console.log
    day: 0, deposit: 10, available: 0.1, CumulativeAvailable: 0.1, cumulativeClaimed: 0.1,

      at Wallet3Ext._printWallet (wallet/wallet-3.ts:31:17)

  console.log
  isMaxPayout: false, isAllClaimed: false, max payout: 36.5, compound: yes, claimedAndSold: 0

      at Wallet3Ext._printWallet (/wallet-3.ts:32:17)

  console.log
    day: 0, deposit: 10, available: 0.1, CumulativeAvailable: 0.1, cumulativeClaimed: 0.1,

      at Wallet3._printWallet (wallet/wallet-3.ts:31:17)

  console.log
      isMaxPayout: false, isAllClaimed: false, max payout: 36.5, compound: yes, claimedAndSold: 0

      at Wallet3._printWallet (wallet/wallet-3.ts:32:17)

But I just want the following:

    day: 0, deposit: 10, available: 0.1, CumulativeAvailable: 0.1, cumulativeClaimed: 0.1,
      isMaxPayout: false, isAllClaimed: false, max payout: 36.5, compound: yes, claimedAndSold: 0
    day: 0, deposit: 10, available: 0.1, CumulativeAvailable: 0.1, cumulativeClaimed: 0.1,
      isMaxPayout: false, isAllClaimed: false, max payout: 36.5, compound: yes, claimedAndSold: 0

What is printed to the console (seen as `jest --testNamePattern=wallet3 run steps alternate day0` but expands to the following):

/Users/boss/.nvm/versions/node/v16.14.0/bin/node --require "/Users/boss/Library/Application Support/JetBrains/Toolbox/apps/WebStorm/ch-0/203.5981.135/WebStorm.app/Contents/plugins/JavaScriptLanguage/helpers/jest-intellij/lib/jest-intellij-stdin-fix.js" /Users/boss/CloudStation/Dev/home/banking/predict/node_modules/jest/bin/jest.js --colors --reporters "/Users/boss/Library/Application Support/JetBrains/Toolbox/apps/WebStorm/ch-0/203.5981.135/WebStorm.app/Contents/plugins/JavaScriptLanguage/helpers/jest-intellij/lib/jest-intellij-reporter.js" --verbose "--testNamePattern=^Wallet3 run steps alternate day 0$" --runTestsByPath /Users/boss/CloudStation/Dev/home/banking/predict/server/src/wallet/wallet-3.spec.ts

(If you click on the shortened version the long version will also be displayed).

I thought it is the reporter so tried changing it by adding this JEST option in the run configuration:

--reporters "/Users/boss/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/203.5981.155/IntelliJ IDEA.app/Contents/plugins/JavaScriptLanguage/helpers/jest-intellij/lib/jest-intellij-jasmine-reporter.js"

But there is only one other reporter in that directory and it requires jasmine.  I also couldn't find " at " in any file.

So how can I change this console.log behaviour?

 

 

 

 

0
3 comments

well, but this output is produced by Jest itself, not by the WebStorm reporter. Here is a result of running jest --env=jsdom __tests__/counter.test.js in terminal:

0

Golly gosh you are correct, although I mentioned the reporters as I thought maybe a different reporter could have been used.

But it seems that this behaviour cannot be avoided through a different reporter, since the reporter stages does not include the output during an actual test run (only startup, after a test suite and when all tests are complete).

So that is disappointing. 

I guess I will just have to run on the command-line with something like this (configure jest-config to select tests instead if you like):

npx jest <spec file> | grep -v " at \|console.log\|^$"

And add a reporter that writes test results to file if you like using this arg:

 --reporters="jest-junit" 

It would be nice if the post-processing could be added to the run configuration.

0

I found the answer - https://stackoverflow.com/questions/50942189/how-to-disable-jest-console-log-tags

 

beforeEach(() => {
    global.console = require('console');
  });
0

Please sign in to leave a comment.