假设测试看起来像这样
describe("suite-1", ()=>{
it("test1",()=> {
...
}
it("test2",()=> {
...
}
}
我想在STDOUT中输出每个测试的名称,比它的每个it()子句更通用。这可能是记者的一个案例。有没有标准的记者呢?
答案 0 :(得分:2)
好哇!
您需要创建一个自定义的Jasmine记者。将以下代码段放在onPrepare挂钩的Protractor配置文件中。我尝试过以下操作并且有效:
onPrepare: () => {
myReporter = {
suiteStarted: function(result) {
console.log('Suite started: ' + result.description);
},
specStarted: function(result) {
console.log('Spec started: ' + result.description);
}
};
jasmine.getEnv().addReporter(myReporter);
}
上详细了解自定义记者
这是我的规范:
import {browser} from 'protractor';
describe('our first Protractor test', () => {
it('should load a page and verify the url', () => {
browser.get('https://angularjs.org/');
expect(browser.getCurrentUrl()).toEqual('https://angularjs.org/');
});
});
这是我的控制台输出:
[18:37:52] I/launcher - Running 1 instances of WebDriver
[18:37:52] I/direct - Using ChromeDriver directly...
Started
Suite started: our first Protractor test
Spec started: should load a page and verify the url
.
1 spec, 0 failures
Finished in 2.541 seconds
答案 1 :(得分:0)
jasmine-spec-reporter可以满足您的需求,它会以这种方式输出结果:
Spec started
suite 1
✓ test 1
✗ test 2
- Expected true to be false.
✓ test 3