描述不是功能,为什么?

时间:2018-12-21 11:37:53

标签: javascript mocha

需要您的帮助,请告诉我我在这里想念的是什么?为什么我收到此错误?

var testCase = require('mocha').describe;
var pre = require('mocha').before;
var assertions = require('mocha').it;
var assert = require('mocha').assert;

testCase('Array', function() {
    pre(function() {
        // ...
    });

    testCase('#indexOf()', function() {
        assertions('should return -1 when not present', function() {
            assert.equal([1,2,3].indexOf(4), -1);
        });
    });
});

enter image description here

 {
  "name": "couponsystem",
  "version": "1.0.0",
  "description": "electron desktop project",
  "main": "src/index.js",
  "scripts": {
    "test": "node src/tests/tests.js"
  },
  "dependencies": {},
  "devDependencies": {
    "chai": "^4.2.0",
    "mocha": "^5.2.0"
  },
  "author": "maks burkov",
  "license": "ISC"
}
  
    

TypeError:testCase不是函数         在对象。 (E:\ JavaScriptProjects \ couponsystem \ src \ tests \ tests.js:6:1)         在Module._compile(内部/模块/cjs/loader.js:688:30)         在Object.Module._extensions..js(内部/模块/cjs/loader.js:699:10)         在Module.load(internal / modules / cjs / loader.js:598:32)         在tryModuleLoad(内部/模块/cjs/loader.js:537:12)         在Function.Module._load(internal / modules / cjs / loader.js:529:3)         在Function.Module.runMain(内部/模块/cjs/loader.js:741:12)         在启动时(internal / bootstrap / node.js:285:19)         在bootstrapNodeJSCore(内部/引导/node.js:739:3)     npm ERR!测试失败。有关更多详细信息,请参见上文。

  

0 个答案:

没有答案