0

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.

Sunny Sachdeva
  • 289
  • 3
  • 16

1 Answers1

5

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.

giri-sh
  • 6,934
  • 2
  • 25
  • 50
  • It worked. I was in impression that If I install it globally it would be accessible from any where. Also did screenshots worked for you. Actually the report is generated but screenshots were not. Are you the same guy who asked this https://github.com/mlison/protractor-jasmine2-screenshot-reporter/issues/10 – Sunny Sachdeva Aug 27 '15 at 10:10