title: Gitlab CI: Build successful even though NPM Error
body: <p>I've currently got my gitlab-ci.yaml file configured with three stages:
  - test
  - deploy
  - publish</p>
  
  <p>Sometimes NPM errors occur if I or a developer forgets to <code>--save</code> an npm package, the <code>-test</code> stage doesn't complete properly, yet still returns "build passed". It'll then go to deploy and publish blindly as the pipeline hasn't been cancelled.</p>
  
  <p>How can I make NPM ERR! stop the current stage and stop the rest from running? </p>
  
  <p>I've simulated this issue by intentionally omitting the bluebird package. It affected the entire test/deploy/publish process and essentially bad code was deployed and run on my server:</p>
  
  <pre><code>  myClass.js
      .selectSpecificXYZ()
        1) Should return an object containing SUCCESS
        2) should return an object regardless of the input
        3) should return an object with count 0
        4) should return an ABC error 
        5) should return a DEF error
  
    Array
      #indexOf()
        ✓ should return -1 when the value is not present
  
  
    1 passing (87ms)
    5 failing
  
    1) myClass.js .selectSpecificXYZ() Should return an object containing SUCCESS when a correct myClass reference is passed:
       Error: Cannot find module 'bluebird'
        at require (internal/module.js:20:19)
        at Object.&lt;anonymous&gt; (api_system/functions/helpers/database_wrappers.js:5:15)
        at require (internal/module.js:20:19)
        at Object.selectXYZByReference (api_system/functions/myClass/myClass.js:55:37)
        at Context.it (api_system/test/myClass/myClassTests.js:19:32)
  
    2) myClass.js .selectSpecificXYZ() should return an object regardless of the input (to handle success or error):
       Error: Cannot find module 'bluebird'
        at require (internal/module.js:20:19)
        at Object.&lt;anonymous&gt; (api_system/functions/helpers/database_wrappers.js:5:15)
        at require (internal/module.js:20:19)
        at Object.selectXYZByReference (api_system/functions/myClass/myClass.js:55:37)
        at Context.it (api_system/test/myClass/myClassTests.js:23:32)
  
    3) myClass.js .selectSpecificXYZ() should return an object with count 0 as there's no value:
       Error: Cannot find module 'bluebird'
        at require (internal/module.js:20:19)
        at Object.&lt;anonymous&gt; (api_system/functions/helpers/database_wrappers.js:5:15)
        at require (internal/module.js:20:19)
        at Object.selectXYZByReference (api_system/functions/myClass/myClass.js:55:37)
        at Context.it (api_system/test/myClass/myClassTests.js:27:30)
  
    4) myClass.js .selectSpecificXYZ() should return an Invalid Parameter error :
       AssertionError: expected [Function] to throw error including 'Invalid Parameter' but got 'Cannot find module \'bluebird\''
        at Context.it (api_system/test/myClass/myClassTests.js:33:73)
  
    5) myClass.js .selectSpecificXYZ() should return an Parameter Too Short error:
       AssertionError: expected [Function] to throw error including 'Parameter Too Short' but got 'Cannot find module \'bluebird\''
        at Context.it (api_system/test/myClass/myClassTests.js:38:79)
  
  
  
  
  npm ERR! Linux 4.4.34-v7+
  npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test" "-recursive"
  npm ERR! node v7.2.1
  npm ERR! npm  v3.10.10
  npm ERR! code ELIFECYCLE
  npm ERR! myServer@1.0.0 test: `mocha api_system/test --recursive`
  npm ERR! Exit status 5
  npm ERR! 
  npm ERR! Failed at the myServer@1.0.0 test script 'mocha api_system/test --recursive'.
  npm ERR! Make sure you have the latest version of node.js and npm installed.
  npm ERR! If you do, this is most likely a problem with the myServer package,
  npm ERR! not with npm itself.
  npm ERR! Tell the author that this fails on your system:
  npm ERR!     mocha api_system/test --recursive
  npm ERR! You can get information on how to open an issue for this project with:
  npm ERR!     npm bugs myServer
  npm ERR! Or if that isn't available, you can get their info via:
  npm ERR!     npm owner ls myServer
  npm ERR! There is likely additional logging output above.
  
  npm ERR! Please include the following file with any support request:
  npm ERR!     /var/www/ci-tests/myServer/npm-debug.log
  [32;1m$ cd ..[0;m
  [32;1m$ rm -rf myServer[0;m
  [32;1m$ cd ..[0;m
  [32;1m$ rm -rf ci-tests[0;m
  [32;1m$ EOF[0;m
  [32;1mBuild succeeded
  [0;m
  </code></pre>