Add test reporting
This commit is contained in:
Родитель
36f689d421
Коммит
57a7ee159c
|
@ -2,6 +2,7 @@
|
|||
|
||||
node_modules/
|
||||
_temp/
|
||||
_results/
|
||||
.vscode
|
||||
gulp-tsc-tmp-*
|
||||
.gulp-tsc-tmp-*
|
||||
|
|
20
gulpfile.js
20
gulpfile.js
|
@ -5,6 +5,7 @@ var process = require('process');
|
|||
var exec = require('child_process').exec;
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var argv = require('yargs').argv;
|
||||
|
||||
function make (target, cb) {
|
||||
var cl = ('node make.js ' + target + ' ' + process.argv.slice(3).join(' ')).trim();
|
||||
|
@ -118,4 +119,21 @@ gulp.task('publishTest', ['packageTest'], function (cb) {
|
|||
// console.log(stderr);
|
||||
// cb(err);
|
||||
// });
|
||||
});
|
||||
});
|
||||
|
||||
// Default to list reporter when run directly.
|
||||
// CI build can pass '--reporter=junit' to create JUnit results files
|
||||
var reporter = 'list';
|
||||
var reporterLocation = '';
|
||||
if (argv.reporter === "junit") {
|
||||
reporter = 'mocha-junit-reporter';
|
||||
reporterLocation = '_results/test-results.xml';
|
||||
}
|
||||
|
||||
gulp.task('testResults', function (cb) {
|
||||
var cmdline = 'test --testResults true --testReporter ' + reporter;
|
||||
if (reporterLocation) {
|
||||
cmdline += ' --testReportLocation ' + reporterLocation;
|
||||
}
|
||||
make(cmdline, cb);
|
||||
});
|
||||
|
|
17
make.js
17
make.js
|
@ -5,7 +5,10 @@ var mopts = {
|
|||
'server',
|
||||
'suite',
|
||||
'task',
|
||||
'version'
|
||||
'version',
|
||||
'testResults',
|
||||
'testReporter',
|
||||
'testReportLocation'
|
||||
]
|
||||
};
|
||||
var options = minimist(process.argv, mopts);
|
||||
|
@ -269,7 +272,17 @@ target.test = function() {
|
|||
fail(`Unable to find tests using the following patterns: ${JSON.stringify([pattern1, pattern2])}`);
|
||||
}
|
||||
|
||||
run('mocha ' + testsSpec.join(' '), /*inheritStreams:*/true);
|
||||
var testResultsArgs = '';
|
||||
if (options.testResults) {
|
||||
if (options.testReporter) {
|
||||
testResultsArgs += ' -R ' + options.testReporter;
|
||||
}
|
||||
if (options.testReportLocation) {
|
||||
testResultsArgs += ' -O mochaFile=' + options.testReportLocation;
|
||||
}
|
||||
}
|
||||
console.log('testResultsArgs=' + testResultsArgs);
|
||||
run('mocha ' + testsSpec.join(' ') + testResultsArgs, /*inheritStreams:*/true);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
"minimatch": "3.0.2",
|
||||
"minimist": "1.1.1",
|
||||
"mocha": "2.3.3",
|
||||
"mocha-junit-reporter": "^1.12.1",
|
||||
"node-uuid": "1.4.6",
|
||||
"q": "1.4.1",
|
||||
"semver": "4.3.3",
|
||||
|
@ -27,6 +28,7 @@
|
|||
"tfx-cli": "^0.3.40",
|
||||
"tslint": "^3.15.1",
|
||||
"typescript": "1.8.7",
|
||||
"validator": "3.33.0"
|
||||
"validator": "3.33.0",
|
||||
"yargs": "^6.4.0"
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче