如何将console.log值传递给protractor-jasmine2-screenshot-reporter

时间:2018-07-19 04:12:09

标签: angular typescript protractor screenshot

请有人可以为以下问题的解决方案提供建议:

我有一个console.log记录一些值的代码,但它们没有导入到protractor-jasmine2-screenshot-reporter的报告中。

如何将这些值传递到报告中,因为它们在日志中可见

我正在针对角度应用运行量角器

我的代码和终端输出

my code and terminal output

我的报告输出

enter image description here

karma.conf.js

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular/cli/plugins/karma')
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    captureTimeout: 120000,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

protractor.conf.js

const HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
var reporter = new HtmlScreenshotReporter({
  dest: './e2e/test_results/stream',
  filename: 'test-results.html',
  reportOnlyFailedSpecs: false,
  captureOnlyFailedSpecs: true,
  showQuickLinks: true,
  reportFailedUrl: true
});...

  jasmine.getEnv().addReporter(reporter);

还有其他记者可以容纳吗?

链接到Github问题:https://github.com/mlison/protractor-jasmine2-screenshot-reporter/issues/123

2 个答案:

答案 0 :(得分:1)

在以下位置查看“其他配置摘要项(可选)”部分 https://www.npmjs.com/package/protractor-jasmine2-screenshot-reporter

基本上,您需要在执行结束时创建报告,并使用上述配置添加所有需要添加的数据。

答案 1 :(得分:0)

也许在定义报告者时可以将其添加到报告标题中:

var reporter = new HtmlScreenshotReporter({
 reportTitle: "Test Report for app" + appNameUsedTrimmed
});