使用mocha chai和Nodejs错误:没有指定testing

我正尝试第一次设置摩卡和柴。 但是,当我在命令行上键入“npm run test”时收到错误消息:“未指定testing”。 在我的package.json文件中,我有:

"scripts": { "start": "node server.js", "test:":"mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive" 

我有一个testing文件夹在我的根与两个文件:

 // 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中的testing脚本中input的内容都会被忽略,而且每次都会得到完全相同的错误消息。

你还没有告诉摩卡你的testing在哪里。 你应该把它指向你的test文件夹:

 mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive ./test 
Interesting Posts