Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@ module.exports = {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}

const processStdoutWrite = process.stdout.write.bind(process.stdout)
process.stdout.write = (str, encoding, cb) => {
// Core library will directly call process.stdout.write for commands
// We don't want :: commands to be executed by the runner during tests
if (!str.match(/^::/)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want anything written out to stdout by the actual process? What if we just drop everything on the floor? Any value in capturing logs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's helpful to have some output for debugging test errors or writing tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, I would either:

  1. Add some prefix to the line, to indicate clearly this is from the actual runner, so that I can easily grep for testing output or proram output; or
  2. Pipe everything to a different place, such as a file.

Personally, I don't like to see my testing result and the actual program's output mingled together. If we add some prefix, will it prevent ::error::s?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what about stderr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I've switched to dropping all of the actual program's output (aka any :: command)
Dropping absolutely everything resulting in losing the --coverage table, and the jest --silent option doesn't handle silencing process.stdout.write

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we don't want to mess with stdout too much then.

return processStdoutWrite(str, encoding, cb);
}
}