Mocha runs only one test

倾然丶 夕夏残阳落幕 提交于 2020-06-18 04:04:41

问题


I have a sails.js app that I want to test with mocha, in my test folder I have 2 tests, but when I run mocha only one test gets executed.

Test1.js

var request = require('supertest');

describe.only('UserController', function() {

  describe('#login()', function() {
    it('should redirect to /mypage', function (done) {
      done();
    });
  });
});

Test2.js

describe.only('UsersModel', function() {

  describe('#find()', function() {
    it('should check find function', function (done) {
      done();
    });
  });
});

I run tests with this command:

./node_modules/.bin/mocha 

Output

UserController
  #login()
    ✓ should redirect to /mypage 


1 passing (10ms)

Please explain me my mistake.


回答1:


It is because you are running an exclusive test by using describe.only(). Use describe() instead.

See exclusive tests in the mocha documentation



来源:https://stackoverflow.com/questions/25473099/mocha-runs-only-one-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!