首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在执行mocha测试时,获取错误“使用类装饰器时需要反射元数据空间”。

在执行mocha测试时,获取错误“使用类装饰器时需要反射元数据空间”。
EN

Stack Overflow用户
提问于 2017-05-23 10:36:42
回答 1查看 801关注 0票数 0

在类型记录中使用chai编写了一个mocha测试用例,并按照文章http://brianflove.com/2016/11/11/typescript-2-express-mongoose-mocha-chai/安装所有依赖项。

当我使用"npm测试“运行测试用例时,我得到了以下错误

使用类装饰器时需要C:\J\MEAN\MSDN-App\node_modules\@angular\core\bundles\core.umd.js:335抛出‘反射-元数据空间’;使用类装饰器npm时需要元数据空间!测试失败了。有关更多细节,请参见上文。

package.json是:

代码语言:javascript
复制
{
  "name": "test-app",
  "version": "1.0.0",
  "description": "test description",
  "main": "server.js",
  "scripts": {
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
    "test": "mocha -r ts-node/register test/**/*.ts",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@angular/common": "^2.0.1",
    "@angular/compiler": "^2.0.1",
    "@angular/core": "^2.0.1",
    "@angular/forms": "^2.0.1",
    "@angular/http": "^2.0.1",
    "@angular/platform-browser": "^2.0.1",
    "@angular/platform-browser-dynamic": "^2.0.1",
    "@angular/router": "^3.4.10",
    "@angular/upgrade": "^2.0.1",
    "@covalent/core": "^1.0.0-beta.3-2",
    "@ngrx/store": "^2.0.1",
    "@types/node": "7.0.7",
    "@types/underscore": "^1.8.0",
    "angular-in-memory-web-api": "^0.1.1",
    "body-parser": "^1.17.1",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "ejs": "^2.5.6",
    "express": "^4.15.2",
    "mongojs": "^2.4.0",
    "node-sspi": "^0.1.14",
    "nodemailer": "^4.0.1",
    "nodemailer-smtp-transport": "^2.7.4",
    "properties-reader": "0.0.15",
    "reflect-metadata": "^0.1.10",
    "rxjs": "5.0.0-beta.12",
    "systemjs": "0.19.39",
    "ts-node": "^3.0.4",
    "underscore": "^1.8.3",
    "zone.js": "^0.6.25"
  },
  "devDependencies": {
    "@types/chai": "^3.5.2",
    "@types/core-js": "0.9.35",
    "@types/mocha": "^2.2.41",
    "chai": "^3.5.0",
    "concurrently": "^3.0.0",
    "lite-server": "^2.2.2",
    "mocha": "^3.4.1",
    "reflect-metadata": "^0.1.10",
    "ts-node": "^3.0.4",
    "typescript": "^2.0.3",
    "typings": "^1.4.0"
  }
}

tsconfig.json是:

代码语言:javascript
复制
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
	"exclude": [
		"node_modules",
		"node_modules/@types",
		"bower_components",
		"typings"
	]
}

请帮助解决错误。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-23 13:08:25

答案很简单,但很难找到。不应该在test.ts文件中包含@ar角/http,为了测试服务使用单元测试,要测试角组件,我们必须使用角度测试实用程序进行测试。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44132418

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档