0

i tried to generate reports by using "'protractor-jasmine2-html-reporter'", but i'm getting module not found exception with error code 5..i tried the somany solutions gathered from stack overflow, but it is not worked. can somebody please help me in this.

Config.js

var Jasmine2HtmlReporter=require('protractor-jasmine2-html-reporter');

exports.config = {
        directConnect : true,
        capabilities:{
                'browserName':'chrome'
        },
          framework: 'jasmine2',
          seleniumAddress: 'http://localhost:4444/wd/hub',
          specs: ['ProtractorTest/PageObjectMain.js'],
          jasmineNodeOpts:{
            defaultTimeoutInterval : 30000  
          },

          onPreapre:function(){
              jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({
                  savePath:"./test-results/report"
              }));
          },
        }

Error log

[14:54:53] E/configParser - Error code: 105
[14:54:53] E/configParser - Error message: failed loading configuration file ReportConfig.js
[14:54:53] E/configParser - Error: Cannot find module 'protractor-jasmine2-html-reporter'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (H:\workspace\Protractor_tutorials\ReportConfig.js:1:88)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)

and my 'Package.Json' not have any details about the report files.. so if that is the problem, please help me to how to configure those in json file.

node-module screenshot

Alex K
  • 22,315
  • 19
  • 108
  • 236
Satish Rongala
  • 209
  • 6
  • 19

4 Answers4

1

There are few things you have to make sure while using Protractor Reporters

1.in my case, in the time creating variable for reporter instead of directly passing Reporter name try to pass the full path of Reporter module.. may this will work Eg :

var Jasmine2HtmlReporter=require('C:/......./npm-modules/protractor-jasmine2-html-reporter');

2.make sure you running the Correct Configuration file having .js extension.

Satish Rongala
  • 209
  • 6
  • 19
1

Installing without save-devworked for me .

Installed globally

npm install -g  protractor-jasmine2-html-reporter

Run below command to link protractor and jasmine2-html-reporter to aovid report not generating issue. Please see Girish Sortur's answer in How to create Protractor reports with Jasmine2

npm link protractor-jasmine2-html-reporter

Also add this import with path to exact node module to avoid the error in windows 10

var Jasmine2HtmlReporter = require('C:/Users/sam/AppData/Roaming/npm/node_modules/protractor-jasmine2-html-reporter');

Full conifg,js that worked for me in windows 10 as per below.

//protractor jasminreporterconfig.js
//Add this import with path to exact node module to avoid the error 
var Jasmine2HtmlReporter = require('C:/Users/sam/AppData/Roaming/npm/node_modules/protractor-jasmine2-html-reporter');

exports.config = {
  framework: 'jasmine',

 capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [ "--start-maximized" ]
         }
    },

      onPrepare: function() {
          jasmine.getEnv().addReporter(
            new Jasmine2HtmlReporter({
           takeScreenshots: true,// By default this is enabled Default is true
           takeScreenshotsOnlyOnFailures: false, // Default is false (So screenshots are always generated)
           cleanDestination: true, // if false, will not delete the reports or screenshots before each test run.Default is true
           showPassed: true,//default is true This option, if false, will show only failures.
           fileName: 'MyRepoDemo', //We can give a prefered file name .
           savePath: 'myproreports',//Reports location it will automatically generated
           screenshotsFolder: 'screenshotsloc' //Screenshot location it will create a folder inside myproreports
            })
          );
       },

  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['src/com/sam/scriptjs/nonangularstackscript.js']

}
Sameera De Silva
  • 1,722
  • 1
  • 22
  • 41
0

It looks like You haven't installed protractor-jasmine2-html-reporter Go to folder where packages are installed (node_modules folder) and run:

npm install protractor-jasmine2-html-reporter
Sanja Paskova
  • 1,110
  • 8
  • 15
  • If want want the package to be automatically added to your `package.json`, then add the `--save` argument: `npm install protractor-jasmine2-html-reporter --save` – Bouke Sep 11 '18 at 11:04
  • @Sanja and Bouke, i installed the jasmine2-reporter but as your suggestion, i deleted and again installed with the same commands.. still getting the same error.. – Satish Rongala Sep 11 '18 at 19:57
  • please refer the attached folders image – Satish Rongala Sep 11 '18 at 20:01
-1

Try to check where the node_modules directory is present by running npm audit and which npm commands. The main thing is path where node_modules is installed should be traced and the new module like npm install protractor-jasmine2-html-reporter can be installed in that path

beruic
  • 5,517
  • 3
  • 35
  • 59
prachi
  • 1
  • Please expand your answer. Perhaps with some commands and expected results that can help solving the issue. Also, have a look at your formatting, and try to format commands, names, etc. as code. I have done some of this for you. – beruic Oct 10 '19 at 11:15