Search code examples
mocha.jschaichai-http

chai-http not exiting after running tests


I ran into a problem where my mocha tests were not finishing after running with chai-http. Mocha just hangs after the tests and eventually runs into a timeout (at least on my CI).


Solution

  • Turns out, Mocha (4.0) changed their behavior regarding the termination of the tests. The best workaround I have found is to add the --exit flag to the npm script to revert to pre-4.0 behaviour.

    ...
    "scripts": {
      "start": "node server.js",
      "test": "mocha --exit"
    },
    ...