找不到量角器结果文件夹' protractor-html-screenshot-reporter'

时间:2016-03-16 10:31:38

标签: node.js npm protractor

我尝试在Protractor中生成报告,然后按照this教程进行操作。

这是我的conf.js文件。

var HtmlReporter = require('protractor-html-screenshot-reporter');
var reporter = new HtmlReporter({
    baseDirectory: 'D:/My Work/Protractor/Financial/protractor-result', // a location to store screen shots.    
    docTitle: 'Protractor Demo Reporter',
    docName: 'protractor-demo-tests-report.html'
});

exports.config = {
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['invoice.js'],
  capabilities: {
    browserName: 'chrome',
  },
  jasmineNodeOpts: {
    showColors: true, // Use colors in the command line report.
  },
  onPrepare: function() {
      jasmine.getEnv().addReporter(reporter);
  }
}

我尝试使用命令protractor conf.js运行此操作,并且没有生成包含测试结果的文件夹。如果我使用命令,则会发生protractor specs\configurations.js跟随错误。

ERROR - failed loading configuration file specs/conf.js
C:\Users\Manuli\AppData\Roaming\npm\node_modules\protractor\lib\configParser.js:
204
    throw e;
    ^

Error: Cannot find module 'D:\My Work\Protractor\Financial\specs\conf.js'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at ConfigParser.addFileConfig (C:\Users\Manuli\AppData\Roaming\npm\node_modu
les\protractor\lib\configParser.js:195:22)
    at Object.init (C:\Users\Manuli\AppData\Roaming\npm\node_modules\protractor\
lib\launcher.js:103:18)
    at Object.<anonymous> (C:\Users\Manuli\AppData\Roaming\npm\node_modules\prot
ractor\lib\cli.js:140:23)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)

为什么我无法生成报告?

提前致谢。 :)

1 个答案:

答案 0 :(得分:0)

我改变了我的conf.js。

var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');

var reporter = new HtmlScreenshotReporter({
  dest: 'D:/My Work/Protractor/Financial/screenshots',
  filename: 'my-report.html'
});

exports.config = {
framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['invoice.js'],
  capabilities: {
    browserName: 'chrome',
  },
 // Setup the report before any tests start
   beforeLaunch: function() {
      return new Promise(function(resolve){
        reporter.beforeLaunch(resolve);
      });
   },

   // Assign the test reporter to each running instance
   onPrepare: function() {
      jasmine.getEnv().addReporter(reporter);
   },

   // Close the report after all tests finish
   afterLaunch: function(exitCode) {
      return new Promise(function(resolve){
        reporter.afterLaunch(resolve.bind(this, exitCode));
      });
   }
}

然后我使用npm install protractor-jasmine2-screenshot-reporter --save-dev命令安装npm。

现在工作。 :)