How to run a single test with Mocha?

前端 未结 12 1153
無奈伤痛
無奈伤痛 2020-12-04 05:46

I use Mocha to test my JavaScript stuff. My test file contains 5 tests. Is that possible to run a specific test (or set of tests) rather than all the tests in the file?

12条回答
  •  清歌不尽
    2020-12-04 06:09

    Consolidate all your tests in one test.js file & your package json add scripts as:

      "scripts": {
      "api:test": "node_modules/.bin/mocha --timeout 10000 --recursive api_test/"
    },
    

    Type command on your test directory:

    npm run api:test
    

提交回复
热议问题