Jasmine report error: ENOENT: no such file or directory, open 'xmlresults.xml'

3.6k Views Asked by At

I'm trying to implement jasmine report to my framework that work with Protractor so in the conf.js i put this code

onComplete: function(){
var browserName;
var capsPromise = browser.getCapabilities();

capsPromise.then(function (caps) {
  browserName = caps.get('firefox');

  var HTMLReport = require('protractor-html-reporter');

  testConfig = {
    reportTitle: 'Test Execution Report',
    outPath: '/test/e2e/reports',
    testBrowser: browserName,
    modifiedSuiteName: false
  };
  new HTMLReport().from('xmlresults.xml', testConfig);
});
},

I already install jasmine reporter with this command

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

When I execute my script is not failing but when the execution try to generate the report in the terminal is displaying this:

E/launcher - ENOENT: no such file or directory, open 'xmlresults.xml'
E/launcher - Error: ENOENT: no such file or directory, open 'xmlresults.xml'

Is anybody has an idea what is happen with this error?

Hope you can help me.

2

There are 2 best solutions below

3
Steve Harris On

Yes, the file cannot be opened at the path you specified because relative to whatever working directory you are in it isn't there.

Change the path to match the relative target location of your XML results file.

0
muthu On

In conf.js, you need to add two functions(onPrepare() and onComplete()). In order to get html report.
In on prepare

var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
    consolidateAll: true,
    savePath: './',
    filePrefix: 'xmlresults'
}));

In onComplete

onComplete: function() {
     var browserName, browserVersion;
     var capsPromise = browser.getCapabilities();
 
     capsPromise.then(function (caps) {
        browserName = caps.get('browserName');
        browserVersion = caps.get('version');
        platform = caps.get('platform');
 
        var HTMLReport = require('protractor-html-reporter-2');
 
        testConfig = {
            reportTitle: 'Protractor Test Execution Report',
            outputPath: './',
            outputFilename: 'ProtractorTestReport',
            screenshotPath: './screenshots',
            testBrowser: browserName,
            browserVersion: browserVersion,
            modifiedSuiteName: false,
            screenshotsOnlyOnFailure: true,
            testPlatform: platform
        };
        new HTMLReport().from('xmlresults.xml', testConfig);
    });
 }