Kenzitron / protractor-jasmine2-html-reporter

HTML reporter for Jasmine2 and Protractor
32 stars 53 forks source link

Screenshot property doesn't work on Windows #22

Open JefferE opened 8 years ago

JefferE commented 8 years ago

On windows I had to change:

screenshotPath = path.join(self.savePath + self.screenshotsFolder, spec.screenshot);

To:

screenshotPath = path.join(self.savePath + "/" + self.screenshotsFolder, spec.screenshot);

Adding the slash between the sections or it was generating these folders:

reports reportsscreenshots

and so the html report was not finding the screenshots it was trying to link as:

src="screenshots/b8e6751cb2a4e1cb1b9ea09ac1d0ef5f.png"

This is my config:

            var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
            var jhtmlReporter = new Jasmine2HtmlReporter({
                consolidateAll: true,
                savePath: 'reports',
                screenshotsFolder: 'screenshots',
                takeScreenshots: true,
                takeScreenshotsOnlyOnFailures: false,
                fixedScreenshotName: false,
                filePrefix: 'index' // Filename for the HTML report
            });
            jasmine.getEnv().addReporter(jhtmlReporter);

If I tried setting this instead:

                savePath: 'reports',
                screenshotsFolder: '/screenshots',

Then it tries to link to:

src="/screenshots/b8e6751cb2a4e1cb1b9ea09ac1d0ef5f.png" But the created folder is still:

reportsscreenshots

Because this line is stripping the leading slash:

self.screenshotsFolder = (options.screenshotsFolder || 'screenshots').replace(/^\//, '') + '/';

guillaumegarcia13 commented 8 years ago

This trick seems to work for me:

jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({
        savePath                     : 'reports//',
        screenshotsFolder            : 'screenshots',
        takeScreenshots              : true,
        takeScreenshotsOnlyOnFailures: false,
        filePrefix                   : 'protractor_report'
    }));
scoobster17 commented 8 years ago

Adding a single trailing slash to 'savePath' value worked for me having the same issue on OSX:

jasmine.getEnv().addReporter(
    new Jasmine2HtmlReporter({
        savePath: 'testing/reports/'
    })
);
shattenjager commented 8 years ago

I tried @scoobster17 solution and it works for me on Windows. Thanks!