nodejs mocha suite is not defined error

前端 未结 3 1312
野趣味
野趣味 2021-02-02 09:13

I am trying to run some tests using mocha but cant seem to get over this error.

E:\\tdd\\nodejs\\cart>mocha cart.test.js

node.js:201
        throw e; // proc         


        
相关标签:
3条回答
  • 2021-02-02 09:21

    You need to tell Mocha to use the TDD interface, instead of the default BDD one:

    mocha --ui tdd card.test.js
    
    0 讨论(0)
  • 2021-02-02 09:28

    You can also include a Makefile in your project and specify TDD like so:

    test:
        @./node_modules/.bin/mocha -u tdd
    
    .PHONY: test
    

    Hat tip: DailyJS

    0 讨论(0)
  • 2021-02-02 09:30

    You can do the same by just specifying mocha -u tdd in package.json

    "scripts": {
    "start" : "node server",      
    "test": "mocha -u tdd" 
     }
    
    0 讨论(0)
提交回复
热议问题