From 8dcef424cea0465cad35cee9a701274363a4d3a2 Mon Sep 17 00:00:00 2001 From: Juanfran Date: Mon, 9 May 2016 13:42:09 +0200 Subject: [PATCH] json e2e reports --- .gitignore | 1 + conf.e2e.js | 24 +++++++++++++++++++++--- package.json | 3 ++- run-e2e.js | 8 +++++++- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index ec0af232..e2d57d5c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ tmp/ app/config/main.coffee scss-lint.log e2e/screenshots/ +e2e/reports/ app/modules/compile-modules/ diff --git a/conf.e2e.js b/conf.e2e.js index c3151a09..d61df045 100644 --- a/conf.e2e.js +++ b/conf.e2e.js @@ -2,8 +2,9 @@ require("babel-register"); require("babel-polyfill"); var utils = require('./e2e/utils'); +var argv = require('minimist')(process.argv.slice(2)); -exports.config = { +var config = { seleniumAddress: 'http://localhost:4444/wd/hub', framework: 'mocha', params: { @@ -101,8 +102,6 @@ exports.config = { // }; // browser.addMockModule('trackMouse', trackMouse); - var argv = require('minimist')(process.argv.slice(2)); - browser.params.glob.back = argv.back; require('./e2e/capabilities.js'); @@ -140,4 +139,23 @@ exports.config = { return browser.get(browser.params.glob.host); }); } +}; + + +if (argv.json) { + var fs = require('fs'); + var dir = './e2e/reports'; + + if (!fs.existsSync(dir)){ + fs.mkdirSync(dir); + } + + var suites = argv.suite.split(',').join('-'); + + process.env['MOCHA_REPORTER'] = 'JSON'; + process.env['MOCHA_REPORTER_FILE'] = 'e2e/reports/report-' + suites +'.json'; + + config.mochaOpts.reporter = 'reporter-file'; } + +exports.config = config; diff --git a/package.json b/package.json index f4350f8e..b904bb30 100644 --- a/package.json +++ b/package.json @@ -84,11 +84,12 @@ "merge-stream": "^1.0.0", "minimist": "^1.1.1", "mocha": "^2.2.4", - "node-uuid": "^1.4.3", "node-sass": "3.6.0", + "node-uuid": "^1.4.3", "photoswipe": "^4.1.0", "pre-commit": "^1.0.5", "readable-stream": "~2.1.2", + "reporter-file": "^1.0.0", "run-sequence": "^1.0.2", "sinon": "^1.14.1", "through2": "^2.0.1", diff --git a/run-e2e.js b/run-e2e.js index ffb1b9c8..f50e6a5f 100644 --- a/run-e2e.js +++ b/run-e2e.js @@ -35,7 +35,13 @@ function backup() { } function launchProtractor(suit) { - child_process.spawnSync('protractor', ['conf.e2e.js', '--suite=' + suit, '--back=' + taigaBackPath], {stdio: "inherit"}); + let protractorParams = ['conf.e2e.js', '--suite=' + suit, '--back=' + taigaBackPath]; + + if (argv.json) { + protractorParams.push('--json'); + } + + child_process.spawnSync('protractor', protractorParams, {stdio: "inherit"}); } function restoreBackup() {