A callback function called once protractor is ready and available, and before the specs are executed You can specify a file containing code to run by setting onPrepare to the filename string.
function () {
        !fs.existsSync(__dirname + '/target') &&  fs.mkdirSync(__dirname + '/target');
        !fs.existsSync(__dirname + '/target/e2e') &&  fs.mkdirSync(__dirname + '/target/e2e');
        
        var reporterPath = path.resolve(path.join(__dirname, '/target/e2e'));
        console.info('The JUnit report will be generated into the following path:', reporterPath);
        
        jasmine
            .getEnv()
            .addReporter(new reporters.JUnitXmlReporter({
                'savePath': reporterPath,
                'consolidate': true,
                'consolidateAll': true
            }));
    }