I have very recently started to use Protractor lib to test angularjs site.I tried to use below 2 libs to create HTML reports but in both cases I got the error
https://www.npmjs.com/package/protractor-jasmine2-html-reporter and https://www.npmjs.com/package/protractor-jasmine2-screenshot-reporter.
Platform:- Windows 7
Installation cmd:- npm install -g protractor-jasmine2-html-reporter
Error: Cannot find module 'protractor-jasmine2-html-reporter'
Config.js
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
var today = new Date(),
timeStamp = today.getMonth() + 1 + '-' + today.getDate() + '-' + today.getFullYear() + '-' + today.getHours() + 'h-' + today.getMinutes() + 'm';
var reporter=new Jasmine2HtmlReporter({
consolidateAll: true,
savePath: 'target/screenshots',
takeScreenshotsOnlyOnFailures: true,
filePrefix: 'index -'+today
});
// An example configuration file.
exports.config = {
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Framework to use. Jasmine 2 is recommended.
framework: 'jasmine2',
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: ['../Test/SmokeTest.js'],
// Options to be passed to Jasmine.
jasmineNodeOpts: {
showColors:true,
defaultTimeoutInterval: 400000,
isVerbose: true,
includeStackTrace: true
},
onPrepare: function() {
jasmine.getEnv().addReporter(reporter);
}
};
Please let me know if I am missing anything. Thanks in advance.
You should be adding the complete path to the protractor-jasmine2-html-reporter when you require it. Try putting in the complete path and then run the test scripts. Here's a sample of it -
var Jasmine2HtmlReporter = require('/usr/local/lib/node_modules/protractor-jasmine2-html-reporter'); //sample for MAC
var Jasmine2HtmlReporter = require('c:/node_modules/protractor-jasmine2-html-reporter'); //sample for windows
Update the path as per your installed folders in your machine. If you don't know where did your node_modules got installed, run the below command to get it -
npm link protractor-jasmine2-html-reporter
Hope it helps.