Archived post: posted sometime between 2016 and 2022.

Parse jest --json test output with jq

The following example installs jq , saves the jest test output to a JSON file, parses the JSON with jq , and then selects only the fullName of tests with a status of "failed" .

sudo apt-get install jq

npm run test --json --outputFile=testOutput.json;

cat testResults.json | jq '.testResults[0].assertionResults | map(select(.status == "failed")) | .[].fullName'

See also: https://stedolan.github.io/jq/