我正在尝试用茉莉花来声明我的angular-5应用程序。在两种情况下,由于茉莉花的行为导致断言失败时,我实际上有两种感觉,其中jasmine
从makeFunc
文件中调用函数jasmine.js
而不是必须调用的函数。 / p>
Senario 1 : 来自助手类的函数在我的组件的方法中被调用,如下所示:
util.ts:
export class Util{
static doSomething(){
return 'hello';
}
}
component.ts:
export class Component{
method(){
let str = Util.doSomething(); // makeFunc is called here instead of Util.doSomething()
// thus, str = undefined in stead of 'hello' during the assertion
}
}
Senario 2 :在相同组件的另一个方法中调用一个方法
component.ts:
export class Component{
func(){
return true;
}
doSomething(){
let bool = this.func(); // makeFunc is called here instead of this.func()
// <- bool = undefined in stead of true during the assertion
}
}
请注意,代码本身可以完美运行。因此,这些既不是误输入也不是拼写错误。
还请注意,我不是在声明这些子例程,而是在声明主方法。但是,子例程的结果对于覆盖每种方法的所有分支都很重要。
断言库:
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2"