这是我的规格文件:
fdescribe('My test', () => {
beforeAll(async () => {
await browser.get('/login'); // usually takes 10 sec.
await LoginPo.login(); // usually takes 1 sec.
await browser.wait(protractor.ExpectedConditions.urlIs('myurl'), 15000);
}, 20000);
afterAll(async () => {
await element(by.id('wrongID')).click();
});
it('dummy test ok', async () => {
await expect(true).toBeTruthy();
});
});
还有我的配置文件的一部分:
exports.config = {
allScriptsTimeout: 11000,
jasmineNodeOpts: {
defaultTimeoutInterval: 5000
},
SELENIUM_PROMISE_MANAGER: false }
通过此配置,我得到了一个茉莉花超时的输出,没有更多相关信息:
Jasmine started
My test
√ dummy test ok
× My test
- Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
**************************************************
* Errors *
**************************************************
1) My test
- Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Executed 1 of 111 specs (1 ERROR) (110 SKIPPED) in 14 secs.
(node:9608) UnhandledPromiseRejectionWarning: Error: 'fail' was used when there was no current spec, this could be because an asynchronous test timed out
at Env.fail (C:\workspace\mdib\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1270:15)
(...)
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:9608) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:9608) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
现在,如果我在20000
中删除了beforeAll()
毫秒的特定茉莉花超时,则会得到以下输出:
Jasmine started
My test
× 1 - dummy test ok
- Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
× My test
- Failed: No element found using locator: By(id, wrongID)
at elementArrayFinder.getWebElements.then (C:\workspace\mdib\node_modules\protractor\built\element.js:814:27)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
From asynchronous test:
(...)
它包括我需要从量角器获取的信息(错误的ID),但虚拟测试失败,并且还包括茉莉花超时,因为应用程序加载花费的时间超过了5000
所定义的defaultTimeoutInterval
毫秒。
我假设,当我设置20000
毫秒茉莉花超时时,量角器失败并且测试永远不会结束,这就是茉莉花超时,隐藏相关的量角器错误日志的原因。
如何在没有Jasmine超时的情况下获得有用的量角器错误日志?
使用jasmine 3.3.0
和protractor 5.4.1
。
答案 0 :(得分:0)
我认为增加defaultTimeoutInterval可以解决问题:
exports.config = {
allScriptsTimeout: 11000,
jasmineNodeOpts: {
defaultTimeoutInterval: 40000
},
SELENIUM_PROMISE_MANAGER: false }