测试用例给出错误:"找不到名称要求"

时间:2016-09-29 06:21:25

标签: node.js unit-testing mocha chai karma-mocha

我已经安装了mocha和chai来编写用typescript

编写的node.js的测试用例

当我运行我的测试用例(npm测试)时,得到如下错误 enter image description here

的package.json:

    {
  "name": "sample",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "mocha --compilers js:babel-register"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel": "^6.5.2",
    "babel-preset-es2015": "^6.14.0",
    "babel-register": "^6.14.0",
    "chai": "^3.5.0",
    "mocha": "^3.0.2"
  },
  "babel":{
    "presets": [
      "es2015"
    ]
  }
}

测试文件:

    "use strict"
/// <reference path="./typings/globals/chai/index.d.ts" />
/// <reference path="./typings/globals/mocha/index.d.ts" />
require('babel-register')({
    presets: ['es2015']
});
import chai = require('chai');
var expect = chai.expect;
// Import the Rectangle class.
let Rectangle = require('./src/db/util/MetricsResponseParser.js');

describe('DistanceDateMetricResponseParser', () => {
  describe('parseResponse', () => {
    let dateTimeMetrics;

    beforeEach(() => {
      dateTimeMetrics = new DistanceDateMetricResponseParser();
    });

    it('Parse Response method ', (done) => {
      // This will fail if "rectangle.width" does
      // not equal 10.
      expect(dateTimeMetrics.parseResponse()).to.equals(Object);
      done();

    });

  });
  });

我还安装了babel,因为它将代码转换为ES5
 我不明白这里的问题

任何帮助将不胜感激

0 个答案:

没有答案