Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor tests reports using jasmine-reporters

I'm trying to export protractor test results to xml files, for that I have installed jasmine-reporters using

npm install -g jasmine-reporters.

Protractor version is Version 2.1.0.

jasmine-reporters version 2.0.7

This is my protracotr config file:

exports.config = {
  seleniumAddress: 'http://localhost:4455/wd/hub',
  capabilities: {
    'browserName': 'chrome'
  },
  specs: [
    'student_spec.js'
    ],  

  onPrepare: function() {      
    require('jasmine-reporters');
    jasmine.getEnv().addReporter(
      new jasmineReporters.JUnitXmlReporter(null, true, true, '/test/e2e/JasmineReporter')
    );
  },
  jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 50000
      }      
};

When I run the protractor, I am getting this error

Error: Cannot find module 'jasmine-reporters'

Help me, where I'm doing wrong.

like image 793
Nagarjuna Reddy Avatar asked Aug 13 '15 09:08

Nagarjuna Reddy


1 Answers

Make sure you have installed jasmine-reporters and the proper path of jasmine-reporters is provided. If it was installed properly then run the below command to see if you get the version of it -

npm list -g jasmine-reporters

If there was a problem installing it, use below command to install it which is compatible with Jasmine 2.x versions -

npm install --save-dev jasmine-reporters@^2.0.0

Update your conf.js file to include proper global scope variable jasmineReporters as mentioned in the package file -

    framework: 'jasmine2',
    onPrepare: function() {
    var jasmineReporters = require('path_of_installed_jasmine-reporters-plugin');
    //update proper path, in my case its ('/usr/local/lib/node_modules/jasmine-reporters')
    jasmine.getEnv().addReporter(
        new jasmineReporters.JUnitXmlReporter(null, true, true, '/test/e2e/JasmineReporter')
    );};
like image 170
giri-sh Avatar answered Sep 20 '22 00:09

giri-sh