[英]Using mocha chai with Nodejs error: no test specified
我正在嘗試首次建立摩卡咖啡和柴。 但是,我在命令行上鍵入“ npm run test”時收到錯誤消息:“未指定測試”。 在我的package.json文件中,我有:
"scripts": {
"start": "node server.js",
"test:":"mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive"
我的根目錄中有一個測試文件夾,其中包含兩個文件:
// test/testhelper.js
import chai from 'chai';
import chaiImmutable from'chai-immutable';
chai.use(chaiImmutable);
// test / immutablespec.js
import {expect} from 'chai';
describe('immutability', () => {
describe('a number', () => {
function increment(currentState){
return currentState + 1;
}
it('is immutable',() => {
let state = 42;
let nextState=increment(state);
expect(nextState).to.equal(43);
expect(state).to.equal(42);
});
});
});
我的控制台上的確切消息是
react-hot-boilerplate@1.0.0 test c:\users\owner\react\voting (my root)
echo 'Error:not test specified'
似乎我在package.json中的測試腳本中鍵入的任何內容都將被忽略,並且每次都會得到完全相同的錯誤味精。
您尚未告訴摩卡您的測試在哪里。 您應該將其指向您的test
文件夾:
mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive ./test
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.