我得到了以下几个测试用例,它们在单独执行时运行成功,但在组中运行时随机失败。它们都使用setTimeout。它们在单独的describe方法中分离的单个spec文件中。
例如:这个测试用例(使用setTimeout)在我自己运行它时通过,但当我在一个组中运行它时,它失败了。我怀疑这个问题与setTimeout有关。我尝试使用done,但这并不能解决问题。
describe('AppComponent Test suite', () => {
let component: AppComponent;
let fixture: Compone
我不想花几个小时阅读代码来找到相关的部分,但我很好奇jasmine是如何实现其时钟的。有趣的是,它可以用同步测试代码来测试异步代码。使用支持ES5的当前node.js,这是不可能的(异步函数在ES7中定义)。它是否使用estraverse之类的东西来解析js代码,并从同步测试中构建异步测试?
这只是我所说的一个例子:
it("can test async code with sync testing code", function () {
jasmine.clock().install();
var i = 0;
var asyncIncrease
在运行角单元测试用例时,我得到了这个错误:
测试结果
SidebarComponent
× should create
TypeError: this.userService.currentUser.subscribe is not a function
sidebar.component.spec.ts
describe('SidebarComponent', () => {
let fixture: ComponentFixture<SidebarComponent>;
let mockUserService;
beforeEa
我一直在使用jasmine和Qunit等单元测试框架测试JavaScript代码。但是所有这些测试框架只能在加载时工作,但我想在运行时启动测试用例,例如,我想像Jasmine中的下面的测试用例那样,在单击按钮时测试对象的值。
function btnClick() {
var temp++;
describe("Test Suite Inside Button Click", function () {
it("To test true value", function
我使用jasmine-node进行单元测试。我做了下面的代码来模拟Date.now()
spyOn(Date, 'now').andReturn(1387636363717); //always return a fixed time
然后我尝试运行jasmine-node spec/,但它停止工作,没有输出。我想不出是什么原因。
我有一个非常奇怪的问题,角2应用程序在火狐和所有的ios浏览器(火狐,safari)
当用户在我的应用程序中输入/reports路由时,我将通过ngOnInit方法调用rest来获取json数据。
这是我的ngOnInit方法中处理数据加载的部分:
ngOnInit() {
//this.service is my service to get reports
this.service.getReports(this.categoryId).subscribe(res => {
this.testReports = res;
}
}
当我得到响应后,我将我