本文介绍了量角器与茉莉花不显示堆栈跟踪以符合错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经完成了一个量角器测试:
I've got a protractor test that does this:
it('Test', async () => {
throw new Error()
}
出现此错误时,它将输出:
When this errors, it outputs this:
✗ Test
- Failed: Error
at callWhenIdle (.../node_modules/jasminewd2/index.js:62:5)
at .../node_modules/jasminewd2/index.js:127:13
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7) (node:43369) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: EPIPE write EPIPE
如何获得有用的堆栈跟踪信息,指出错误已在测试的相应行上抛出?
这是我的量角器配置文件:
Here's my protractor configuration file:
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const {SpecReporter} = require('jasmine-spec-reporter');
var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
var reporter = new HtmlScreenshotReporter({
dest: '../build/test-results/e2e/screenshots',
filename: 'e2e-report.html',
reportOnlyFailedSpecs: true,
captureOnlyFailedSpecs: true,
showQuickLinks: true,
reportFailedUrl: true,
inlineImages: true
});
exports.config = {
SELENIUM_PROMISE_MANAGER: false,
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome',
chromeOptions: {
args: ["--headless", "--disable-gpu", "--window-size=1920,1080"]
}
},
directConnect: true,
baseUrl: 'http://localhost:4201/',
params: {},
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function () {
}
},
beforeLaunch: function () {
return new Promise(function (resolve) {
process.on('uncaughtException', function () {
reporter.jasmineDone();
reporter.afterLaunch();
});
reporter.beforeLaunch(resolve);
});
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(reporter);
jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}}));
console.log("==========> Target report configuration", browser.params.products[process.env.TARGET_REPORT_SKU]);
},
afterLaunch: function (exitCode) {
return new Promise(function (resolve) {
reporter.afterLaunch(resolve.bind(this, exitCode));
});
}
};
对于它的价值,我正在通过gradle命令运行测试.
For what it's worth, I'm running the tests through a gradle command.
我尝试创建一个新的量角器应用程序,发现它存在相同的问题.因此,我在他们的github上创建了一个问题: https://github.com/angular/protractor/问题/4975
I tried creating a fresh protractor app and saw that it had the same problem. Therefore, I created an issue on their github: https://github.com/angular/protractor/issues/4975
推荐答案
内部量角器配置添加到 jasmineNodeOpts 此选项.
Inside protractor config add to jasmineNodeOpts this option.
这篇关于量角器与茉莉花不显示堆栈跟踪以符合错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!