- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有人可以帮助我解决单元测试问题吗?我正在尝试使用 Angular2 进行测试,因此我有以下 tests/example.ts
文件:
import {beforeEachProviders, inject} from "@angular/core/testing";
import {CloudService} from "../Shared/Cloud/cloud.service";
import {Login} from "../Components/Dock/Login/login.component";
describe('1st tests', () => {
it('true is true', () => expect(true).toEqual(true));
});
describe('Login Component', () => {
var _cloudService = new CloudService;
var login = new Login(_cloudService);
beforeEachProviders(() => [CloudService]);
it("Toggles Child Opacity on Click", function() {
expect(login.google.nativeElement.style.opacity.toEqual(0)); //Check if the counter equals 42.
});
});
如果我只有第一个测试,一切都运行良好,但在第二个测试(Angular 测试)中,我得到以下输出:
JS: NSUTR: successfully connected to karma
17 06 2016 13:39:52.033:INFO [NativeScript / 23 (6.0; Google Nexus 6 - 6.0.0 - API 23 - 1440x2560)]: Connected on socket /#RVDKwphYh_vDt9dxAAAA with id NativeScriptUnit-6168
JS: NSUTR: downloading http://192.168.101.2:9876/context.json
JS: NSUTR: disregarding second execution
JS: NSUTR: eval script /base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?391e45351df9ee35392d2e5cb623221a969fc009
JS: NSUTR: eval script /base/node_modules/karma-jasmine/lib/boot.js?945a38bf4e45ad2770eb94868231905a04a0bd3e
JS: NSUTR: eval script /base/node_modules/karma-jasmine/lib/adapter.js?7975a273517f1eb29d7bd018790fd4c7b9a485d5
JS: NSUTR: require script /base/app/tests/example.js?a455c4e9fa5e9b056e0c931845325f514b63be7f from ../../tests/example.js
JS: NSUTR: this.error: reflect-metadata shim is required when using class decorators
JS: at ../../tests/example.js 17 06 2016 13:39:53.605:WARN [NativeScript / 23 (6.0; Google Nexus 6 - 6.0.0 - API 23 - 1440x2560)]: Adapter did not report total number of specs. NativeScript / 23 (6.0; Google Nexus 6 - 6.0.0 - API 23 - 1440x2560): Executed 0 of 0 SUCCESS (0 secs / 0 secs)
NativeScript / 23 (6.0; Google Nexus 6 - 6.0.0 - API 23 - 1440x2560) ../../tests/example.js at line 0 FAILED reflect-metadata shim is required when using class decorators NativeScript / 23 (6.0; Google Nexus 6 - 6.0.0 - API 23 - 1440x2560):
Executed 1 of 0 (1 FAILED) ERROR (0.114 secs / 0 secs)
JS: NSUTR: completeAck
JS: NSUTR-socket.io: io server disconnect
如果我将行 import "reflect-metadata";
添加到文件中,我会得到相同的结果...
你知道我做错了什么吗?
最佳答案
这已经很旧了,但我想我应该发表评论,以防其他人偶然发现这个问题。
我一直遇到这个问题,它让我发疯。我找到了一种解决方法,将转译的 Javascript 文件模式添加到我的 karma.config 中。我还必须从 karma.config 中删除 Typescript 文件模式。这不是我所希望的,但对于其他寻求此问题答案的人来说,这是一种解决方法。
关于javascript - Natviescript 中的 Angular 单元测试 : reflect-metadata shim is required when using class decorators,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37882448/
我正在尝试使用更新的包重建项目但遇到此错误: [folatt@ArkOS-Dev genesis]$ ember build cleaning up... Build failed. The Broc
我正在尝试使用更新的包重建项目但遇到此错误: [folatt@ArkOS-Dev genesis]$ ember build cleaning up... Build failed. The Broc
鉴于以下情况: main.js var angular = require('angular'); 包.json { "main": "./main.js", "browser": {
我正在编写将一些数据放入分类帐的链码,然后尝试使用shim.GetStateByPartialCompositeKey()将其列出,并从迭代器中获取数据列表。现在,我想根据时间戳对数据进行排序(仅按日
我想为通用方法创建一个垫片。但在那种情况下,我对 Generic 有点麻烦。 这是我的例子: class BaseRepository where T: Entity { public T[
如主题所示。我的文件结构是: js/ |- bootstrap | |- module1 | |- module2 | |- jquery.min.js |- main.js 我的
该术语的官方解释是 es5-shim.js and es5-shim.min.js monkey-patch a JavaScript context to contain all EcmaScrip
它has been stated那: The shim allows for daemonless containers. It basically sits as the parent of the
据我了解,您可以使用 Requirejs 的填充程序来动态加载未在自己的文件中定义为模块的脚本。那么为什么我不能让这样一个简单的脚本工作呢? 这是我的非工作示例: /libs/test.js: var
我想将 bootstrap.js 和 jquery.js(均随 npm 安装)合并到vendors.js 文件中,但仍然可以通过调用 require('$') 来使用 jquery。所以我创建了 gu
我正在尝试获取与 magento 2 requirejs 一起使用的常量联系人脚本。 (我尝试将其内联添加,但它会发生冲突并导致错误) 他们的脚本需要数组 localizedErrMap 和 jQue
我发现自己需要这样的东西: // This could just as well be a concrete class. // // It is an interface for the sake
我正在尝试将现有应用程序分解为多个模块。我选择使用 Browserify 来做到这一点,因为它的语法很好地模仿了 NodeJS 的要求。 我的项目依赖于几个外部模块,其中之一是 Backbone。因此
我想将两个变量($ 和 jQuery)从 jquery 包传递到 persian-datepicker。因此,我添加了 $ 和 jQuery 作为 persian-datepicker 的依赖项。我所
我在 browserify-shim 和 bootstrap-datetimepicker 方面遇到问题。 Bootstrap-datetimepicker 需要 moment.js 但必须先加载此插
我想针对某些错误的网络行为测试存储库。我使用 MS Fakes 伪造了类(class),它看起来像这样: ShimInputRepository .AllInstanc
我在 vs 2015 上运行 angularjs2/TypeScript 项目 并按照 https://www.typescriptlang.org/docs/handbook/asp-net-4.h
我有一个测试方法,当我运行它时它很好,但在调试时失败并出现异常。下面是经过测试的方法和 VS Test Runner 的输出。异常来自 ShimsContext.Create() 信息:VS 2012
在为 BCL(或与此相关的任何库)中的类型成员创建垫片时。我们经常遇到这样一种情况,我们想要调用我们已经覆盖的原始方法(无论是在 shim 委托(delegate)内部还是外部)。例如: System
在 Visual Studio 2015 中,我有一个测试项目,我向其中添加了一个假程序集。 在单元测试本身中,我为静态泛型方法创建了一个垫片,该方法将实例返回到泛型类型,例如: using (Shi
我是一名优秀的程序员,十分优秀!