我正在使用一个指令来获取用作过滤器文本的输入数据.
这是我在指令中的hostlistener:
@HostListener('input', ['$event.target.value'])
public onChangeFilter(event: any): void {
console.log('input event fired, value: ' + event);
this.columnFiltering.filterString = event;
this.filterChanged.emit({filtering: this.columnFiltering});
}
Run Code Online (Sandbox Code Playgroud)
这段代码工作正常,我无法进行单元测试.
我订阅了filterChanged EventEmitter,在我的单元测试中检查了值.
我尝试模拟按键事件来更改值并尝试设置值属性.这些都不适合我.
这是我的spec文件:
describe('Table View', () => {
let fixture: ComponentFixture<any>;
let context: TableComponent;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
TableComponent,
],
imports: [TableModule],
});
fixture = TestBed.createComponent(TableComponent);
context = fixture.componentInstance;
});
it('should allow filter', () => {
const element = fixture.nativeElement;
context.config = config;
fixture.detectChanges();
let tableChangeCount = 0;
let tableEvent: any;
context.tableChanged.subscribe((event: any) => …Run Code Online (Sandbox Code Playgroud) 我正在使用Karma-coverage生成代码覆盖.我可以在http-server上托管我的输出覆盖文件夹并在本地查看它.
如何在VSTS代码覆盖率选项卡上显示此报告?
我是否需要在VSTS兼容中重新格式化我的覆盖率结果?
我已经阅读了关于vsts-tasks的内容,但我不知道如何实现相同的目标.
任何帮助表示赞赏.
code-coverage azure-devops azure-pipelines angular azure-devops-rest-api
我在对我编写的行为进行单元测试时遇到问题。行为如下:
NumericTextBoxBehavior : Behavior<TextBox>
{
//handles few events like TextChanged ,PreviewTextInput , PreviewKeyDown , PreviewLostKeyboardFocus
//to give make it accept numeric values only
}
Run Code Online (Sandbox Code Playgroud)
在单元测试相同的同时我编写了这段代码
TextBox textBoxInvoker = new TextBox();
NumericTextBoxBehavior target = new NumericTextBoxBehavior();
System.Windows.Interactivity.Interaction.GetBehaviors(TextBoxInvoker).Add(target);
Run Code Online (Sandbox Code Playgroud)
现在要提出这个事件我必须打电话
textBoxInvoker.RaiseEvent(routedEventArgs)
Run Code Online (Sandbox Code Playgroud)
此路由事件参数又将路由事件作为参数。
请帮助我如何创建模拟 RoutedEventArgs 来引发事件并进一步对行为进行单元测试。
提前致谢。
在我们的应用程序中,我们必须从后端服务中获取用户上下文。如果用户上下文发生变化,应用程序需要重新加载。因为用户可以在不同的选项卡中更改他们的上下文。我们每 5 秒 ping 我们的后端服务以检查用户上下文是否已更改。
有没有办法检测用户是否已停用或激活当前选项卡?这将节省每 5 秒 ping 后端一次。
用户可以在同一应用程序或其他应用程序的不同选项卡中更改上下文。
我用relative Paths在我创建导入模块Angular2和TypeScript应用。
示例 (源代码)
import {Http} from 'angular2/http';
import {Injectable} from 'angular2/core';
import {Person} from '../core/Person';
Run Code Online (Sandbox Code Playgroud)
这在 windows (tsc v1.7.5) 上编译得很好,但不能在 Linux 上加载。
问题:
- 为什么这在 linux 上表现如此?
- 有没有标准方法可以在打字稿中声明模块的路径?
配置文件
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"wwwroot/lib"
]
}
Run Code Online (Sandbox Code Playgroud)
Ubuntu 14.04 上的错误
wwwroot/app/people/people.service.ts(3,22): 错误 TS2307: 找不到模块“../core/Person”。wwwroot/app/routes.config.ts(1,22): 错误 TS2307: 找不到模块“./home/Home”。wwwroot/app/routes.config.ts(2,23): 错误 TS2307: 找不到模块“./about/About”。wwwroot/app/routes.config.ts(3,24): 错误 TS2307: 找不到模块“./people/People”。wwwroot/app/routes.config.ts(4,30): 错误 …
我正在尝试将 Jest 集成到我的 Angular 应用程序中。根据笑话配置,我可以配置记者,但它不允许我设置 Cobertura 的输出文件名。要配置其他自定义记者,我可以使用记者字段,它们允许提供额外的配置。如何将我的文件命名为 cobertura.xml。
请帮忙!
coverageReporters: [
"text",
"lcov",
"cobertura"
],
reporters: ["default", "jest-junit"],
Run Code Online (Sandbox Code Playgroud) angular ×5
unit-testing ×2
azure-devops ×1
behavior ×1
browser ×1
c# ×1
input ×1
jasmine ×1
jestjs ×1
keypress ×1
linux-mint ×1
tabs ×1
textbox ×1
ubuntu-14.04 ×1
wpf ×1