Nodejs|Mocha测试

2017-12-28  本文已影响0人  绍重先

npm install --save mocha

  "scripts": {
    "start": "node ./bin/www",
    "test" : "mocha"
  },

mkdir test

function wordGainsScore(str) {
 .....
module.exports = wordGainsScoreHtml;
var assert = require('assert');
var wordGainScore = require('../js/wordGainScore');

describe('Q1:wordGainScore',function(){
    it('should return 0 when string is bcd',function(){
        assert.equal(0,wordGainScore('bcd'));
    });

    it('should return 15 when string is AeIoU',function(){
        assert.equal(15,wordGainScore('AeIoU'));
    });
});

npm test

上一篇 下一篇

猜你喜欢

热点阅读