简体   繁体   中英

Using mocha chai with Nodejs error: no test specified

I am trying to set up Mocha and Chai for the first time. However, I am getting error message: "No test specified" when I type "npm run test" on the command line. In my package.json file, I have:

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

I have a test folder in my root with two files:

// 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);

        });
    });
});

The exact message on my console is

react-hot-boilerplate@1.0.0 test c:\users\owner\react\voting (my root)
echo 'Error:not test specified'

It appears that anything I type in my test script in package.json gets ignored and I get the exact same error msg each time.

You haven't told mocha where your tests are. You should point it at your test folder:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM