Do you want to request a feature or report a bug?
A feature!
What is the current behavior?
Currently Jest (as do many modern CLI tools) outputs fancy text to the terminal for a better experience. This does things like only painting part of the terminal, colors, and other stuff like that.
The problem is if you get too fancy you break interop with all other unix tools. For example, do jest | less
and it won't work. You'll see lots of weird characters and the output is not paged.
I really want to get a list of all currently failing tests. Just a raw list, don't want to see a huge amount of actual/expected output (the diffs can be very large). I'm migrating a test suite over to new code so my goal is to make all these tests pass. Right now it's very hard to track just the failing tests.
Doing jest | grep FAIL
would work if I could grep the output, but I can't.
What is the expected behavior?
Provide some sort of --simple-output
which just dumps raw text and newlines to the terminal, without any of the fancy stuff. This would let me grep the output and the test failures, or do anything you want to with any of the normal unix tools.
@jlongster thanks for adding this issue. Something similar was already discussed here: #2292 and there's also a temporary solution: https://github.com/facebook/jest/issues/2292#issuecomment-266610605 while we don't have --simple-output
or --no-interactive
or --no-status
Cool,thanks! While CI=true
seems to remove the summary output at the bottom, it still does not interact well with less
or grep
. I'm wondering if it's using a different type of newline or something.
As a workaround you can redirect stderr (which holds results) to stdout
CI=true npm test 2>&1 | grep fail -i
But having --no-status, or --no-interactive would still be great to have
Ah nice, thanks! I thought everything was piped to stdout because the --useStderr
option exists.
A workaround we came up with is to create a file test.sh
that would allow you to handle non-interactive shells gracefully while maintaining the exit code.
#!/bin/bash
if [ "`tty`" != "not a tty" ]
then
echo 'Interactive shell'
./node_modules/.bin/jest ./spec/$1/*
EXIT_CODE=$?
exit $EXIT_CODE
else
echo 'Non interactive shell'
./node_modules/.bin/jest ./spec/$1/* > ./jest-output.log 2>&1
EXIT_CODE=$?
cat ./jest-output.log
rm ./jest-output.log
exit $EXIT_CODE
fi
while in package.json
"scripts": {
"test-unit": "sh test.sh unit",
"test-integration": "sh test.sh integration"
}
This is obviously temporary until a proper fix is merged to master.
Please add that flag as a feature since a lot of people use Jenkins for CI.
I came across this issue today when trying to get debug (https://github.com/visionmedia/debug) output to appear while debugging a test case. Had to solve it using the workarounds in other issues, namely:
$ CI=true DEBUG=* ./node_modules/.bin/jest --env=jsdom --watch
Without CI=true _no_ output from the debug module will be seen (or it will be seen briefly if a test is slow, but jest will erase it).
The watch/automatic mode of jest is really cool! Has really changed my workflows. But taking over stderr/stdout has also caused me to spend more time than I'd like to admit trying to have confidence in my debug output.
I'm trying to run Jest inside a maven process, and it hangs every time, and I don't know but I _suspect_ it's related to the clever output. 馃憤
I confirmed the CI=true
made it work inside the maven build. 馃嵒 Since we are using frontend-maven-plugin I had to add environment variables in the pom like so:
...
<configuration>
...
<environmentVariables>
<CI>true</CI>
</environmentVariables>
</configuration>
...
I think for now we aren't interested in doing this but if anybody feels strongly, please send a PR :)
Most helpful comment
As a workaround you can redirect stderr (which holds results) to stdout
But having --no-status, or --no-interactive would still be great to have