我想设置一个在jasmine
完成所有任务之后运行的回调。
这是我尝试过的:
package.json
{
"scripts": {
"test": "jasmine"
}
...
"jasmine": "^2.8.0"
}
spec / support / jasmine.json
{
"helpers": [
"helpers/env.js",
"helpers/**/*.js"
],
...
}
spec / helpers / env.js
jasmine.onComplete( () => console.log('yay, done') )
但要不断出错
$ npm test
...
jasmine.onComplete( () => console.log('yay, done') )
^
TypeError: jasmine.onComplete is not a function
...
答案 0 :(得分:1)
看来,
您不会初始化Jasmine。
var Jasmine = require('jasmine');
var jasmine = new Jasmine();
引用this:
然后这应该起作用:
jasmine.onComplete(function(passed) {
if(passed) {
console.log('All specs have passed');
}
else {
console.log('At least one spec has failed');
}
});