gpt4 book ai didi

angular - Protractor 与 Jasmine 不会显示堆栈跟踪以符合错误

转载 作者:行者123 更新时间:2023-12-03 05:41:36 28 4
gpt4 key购买 nike

我有一个 protractor 测试可以做到这一点:

  it('Test', async () => {
throw new Error()
}

当此错误时,它将输出以下内容:
    ✗ 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

如何获得有用的堆栈跟踪信息,说明错误在测试的相应行上抛出?

这是我的 protractor 配置文件:
// 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));
});
}
};

对于它的值(value),我正在通过gradle命令运行测试。

我尝试创建一个新的 protractor 应用程序,发现它有同样的问题。因此,我在他们的github上创建了一个问题: https://github.com/angular/protractor/issues/4975

最佳答案

在 protractor 的内部配置中,将此选项添加到 jasmineNodeOpts 中。

includeStackTrace: true

关于angular - Protractor 与 Jasmine 不会显示堆栈跟踪以符合错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52729217/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com