本文介绍了摩卡咖啡仅运行一项测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个sails.js应用程序,我想用mocha进行测试,在我的测试文件夹中,我有2个测试,但是当我运行mocha时,只有一个测试被执行.
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
输出
UserController
#login()
✓ should redirect to /mypage
1 passing (10ms)
请向我解释我的错误.
推荐答案
这是因为您正在使用describe.only()
运行排他测试.改为使用describe()
.
It is because you are running an exclusive test by using describe.only()
. Use describe()
instead.
请参阅Mocha文档中的专有测试
See exclusive tests in the mocha documentation
这篇关于摩卡咖啡仅运行一项测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!