Issue
I had a build on our CI server failing with this message:
+ npm run coverage
> [email protected] coverage /home/jenkins/workspace/workspace/ololCloud_service-monitor_PR-3568
> nyc --reporter=lcov --include='**/*.js' npm run test:ci
> [email protected] test:ci /home/jenkins/workspace/workspace/erayCloud_service-monitor_PR-3568
> TLL_MONITOR_UPLOAD_WAIT_TIME=0 TLL_DEFAULT_WAIT_TIMEOUT=0 ./node_modules/.bin/mocha --timeout 120000 --reporter=xunit --reporter-options output=./test-results/TEST-results.xml --require @babel/register --exit ./test/monitor-unit-test-suite.js
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:ci: `TLL_MONITOR_UPLOAD_WAIT_TIME=0 TLL_DEFAULT_WAIT_TIMEOUT=0 ./node_modules/.bin/mocha --timeout 120000 --reporter=xunit --reporter-options output=./test-results/TEST-results.xml --require @babel/register --exit ./test/monitor-unit-test-suite.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:ci script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/jenkins/.npm/_logs/2021-10-21T19_09_07_920Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] coverage: `nyc --reporter=lcov --include='**/*.js' npm run test:ci`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] coverage script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/jenkins/.npm/_logs/2021-10-21T19_09_08_438Z-debug.log
script returned exit code 1
There is no information in these logs, and the mentioned file 2021-10-21T19_09_08_438Z-debug.log
does not have anything else either.
How can I find the information I need?
Solution
TL;DR: Look for files where the error messages might have been saved to. There may be hints in console output.
It is up to the apps called by NPM to print the needed information. In other words: you probably should change your build code (probably your package.json
) to display the log you need. Often, it is not practical or even viable, but that's the general approach.
OTOH, sometimes the information is being sent to a different place. For example, consider the line below, taken from the output in the question and broken into lines for more legibility:
npm ERR! [email protected] test:ci:
`TLL_MONITOR_UPLOAD_WAIT_TIME=0\TLL_DEFAULT_WAIT_TIMEOUT=0 ./node_modules/.bin/mocha
--timeout 120000
--reporter=xunit
--reporter-options output=./test-results/TEST-results.xml
--require @babel/register
--exit ./test/monitor-unit-test-suite.js`
Notice that ./node_modules/.bin/mocha
has the flag --reporter-options output=./test-results/TEST-results.xml
. It is not hard to imagine test results are written to the file ./test-results/TEST-results.xml
. Our error messages are more likely there.
Indeed, I looked there and found these lines:
<testcase
classname="Utils tests Config Watcher Tests Reload Config"
name="Should reload configs, after file events" time="1.002">
<failure>the string "Reload wait timeout 1000ms exceeded" was thrown, throw an Error :)
Error: the string "Reload wait timeout 1000ms exceeded" was thrown, throw an Error :)</failure>
</testcase>
<testcase
classname="Utils tests Config Watcher Tests Schedule Reload"
name="Should reload config, after scheduled reload" time="1.001">
<failure>the string "Reload wait timeout 1000ms exceeded" was thrown, throw an Error :)
Error: the string "Reload wait timeout 1000ms exceeded" was thrown, throw an Error :)</failure>
</testcase>
There it is, the root cause of the build failure.
The rule of thumb is :
Look for files where the command's output might have been saved.
Flags with words like output
, logfile
, redirect
etc., are potential output redirectors.
It is not a definitive solution. You may not have access to these files on CI etc. Yet, I'd try this rule of thumb before despairing.
Answered By - brandizzi
Answer Checked By - Marilyn (JavaFixing Volunteer)