How Mocha knows which file to load first in the test suite

前端 未结 3 1379
抹茶落季
抹茶落季 2021-02-08 13:58

I\'m trying to learn the A Test Driven Approach with MongodB. The folder structure

A user.js to test in the src folder

const mongo         


        
3条回答
  •  心在旅途
    2021-02-08 14:46

    There is a very easy way to load tests sequentially.

    Step 1 : Set up a test script in package.json: e.g.

    "scripts": {
        "test": "mocha ./tests.js"
      }
    

    Let us assume that tests.js is a file which defines the order to execute tests.

    require("./test/general/test_login.js");
    require("./test/Company/addCompany.js");
    ...
    ...
    

    So here test_login will run first and then others one by one.

    Step 2: Then run tests with:

    $ npm test
    

提交回复
热议问题