不能使用var HtmlReporter = require('protractor-html-screenshot-reporter')

我需要在量angular器中生成testing报告。 我经历了一些教程,这些教程不是很清楚。

当我试图安装npm时,发生以下错误。

在这里输入图像说明

在运行这个名为node_modules的文件夹之后创build。 但是,我不明白为什么我不能安装npm。 请帮忙。

– 编辑 –

我正在使用本教程来生成量angular器报告。

我添加了var HtmlReporter = require('protractor-html-screenshot-reporter')到我的conf.js这是我的完整文件。

 // conf.js 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. } var HtmlReporter = require('protractor-html-screenshot-reporter'); var reporter=new HtmlReporter({ baseDirectory: './protractor-result', // a location to store screen shots. docTitle: 'Protractor Demo Reporter', docName: 'protractor-demo-tests-report.html' }); exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', specs: ['invoice.js'], onPrepare: function() { jasmine.getEnv().addReporter(reporter); } } } 

发生以下错误。

在这里输入图像说明

请告诉我应该怎么做。 提前致谢。

您的conf.js格式错误 – 您无法在对象定义中定义variables。 它应该看起来像这样:

 var HtmlReporter = require('protractor-html-screenshot-reporter'); var reporter = new HtmlReporter({ baseDirectory: './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); } } 

请注意,我从来没有使用过量angular器,所以我不能保证这是一个工作的configuration,但它应该sorting你的语法错误。