travisjeffery / mocha-teamcity-reporter

MIT License
40 stars 48 forks source link

Stdout/stderr from tests aren't properly wrapped I think #68

Open vlovich opened 1 year ago

vlovich commented 1 year ago

The problem

My experience with Jest & Jest-teamcity has been that console.X messages are written wrapped with the relevant TeamCity adoration to assign the output to the running test it was for. However, this reporter seems to treat console.X messages as passthrough. Another niggle is that when using Miniflare 3, you can get output to stdio directly from workerd. So it would be nice if stdout and stderr were redirected into the reporter on launch and adorned with the appropriate TeamCity wrapper text to assign it to the specific test generating that output..

Environment

Details

An example test or code sample

example.test.js:

test('abc', async () => {
   console.error('waiting')
   await new Promise((resolve) => setTimeout(resolve, 100))
   process.stdout.write('finished wait\n')
})

I would expect waiting and finished wait to be printed adorned with TeamCity service messages assigning that output to test abc.

As I understand it, TeamCity only allows a single testStdOut / testStdErr per test so it sounds like you have to buffer stdout / stderr to memory/disk and then output it BEFORE writing out testFinished / testFailed. That being said, I have my own custom wrapper that I wrote using teamcity-service-message for non-mocha things and generating multiple testStdout / testStderr lines repeatedly seems to maybe work (although maybe I'm just not noticing the failure mode).

SimonFischer04 commented 1 month ago

experiencing same issue here, @vlovich have you found a solution yet?