The test ride before Mr. Wiryo’s bike goes back: how test.js ends (exit, exitCode, throw, SIGKILL) becomes one number, and the CI runner reads that number…
"Why did the deploy run when the test failed?" is nearly always about that number: a ; or a pipe that swallows it, an || echo that turns it into 0, a shell without -e or without pipefail. Reading exit codes makes a green CI trustworthy, and a 137 in the log reads at once as a killed process, not a failed test.
0 succeeds, anything else fails, and a CI step reads one number
0 for failure, like false The other way round: 0 succeeds, any other number fails. There is one way to succeed and many to fail, so each non-zero number can name its kind of failure (1 general, 2 misuse, 127 command not found, 137 killed).; and taking it for && ; runs the next command whatever happened, and the line’s code is the last command’s: a failed test can end green. Use &&. bash -e (GitHub’s default) stops at a failure too, but an npm script runs under sh without -e.$? is the last command’s alone A run line’s code is the last command that ran, and a pipeline’s code is its last command’s: npm test | tee log.txt exits 0 even when the test fails. Write shell: bash so GitHub uses -o pipefail, or set -o pipefail at the start of the line.process.exitCode = 2 The script runs to the end, then exits 2.; In an npm script, npm test ; npm run build exits 0 and the bike goes back.npm test | tee exits 0 until shell: bash turns pipefail on.