display slow tests after suite has finished

This commit is contained in:
Román Jiménez 2017-08-28 19:44:19 +02:00
parent 9aec3c2cd8
commit ae839dbd3f
2 changed files with 18 additions and 0 deletions

View File

@ -77,6 +77,7 @@ module.exports = function(grunt) {
browser: 'phantomjs',
headless: false,
chromePoll: 100,
reportSlowerThan: -1,
version: '2.2.0',
timeout: 10000,
styles: [],
@ -269,6 +270,7 @@ module.exports = function(grunt) {
tabstop = 2,
thisRun = {},
suites = {},
slowSpecs = [],
currentSuite;
status.failed = 0;
@ -366,6 +368,11 @@ module.exports = function(grunt) {
failureMessages: []
};
if (options.reportSlowerThan !== -1 &&
specMetaData.duration > options.reportSlowerThan) {
slowSpecs.push(specMetaData);
}
suites[currentSuite].tests++;
var color = 'yellow',
@ -465,6 +472,14 @@ module.exports = function(grunt) {
logSummary(thisRun.summary);
}
if (options.reportSlowerThan !== -1 && slowSpecs.length > 0) {
grunt.log.writeln(chalk.yellow('Some specs were slower than ' + options.reportSlowerThan + ' ms:'));
grunt.log.writeln();
_.forEach(slowSpecs, function (slowSpec) {
grunt.log.writeln(chalk.yellow(slowSpec.fullName) + chalk.red(' (' + slowSpec.duration + ' ms)'));
})
}
if (options.junit && options.junit.path) {
writeJunitXml(suites);
}

View File

@ -8,6 +8,7 @@
}
var ChromeReporter = {
lastSpecStartTime: null,
jasmineStarted: function (suiteInfo) {
console.log('Jasmine started: ', new Date().toString());
pushToQueue({
@ -23,12 +24,14 @@
});
},
specStarted: function (result) {
this.lastSpecStartTime = new Date();
pushToQueue({
type: 'jasmine.specStarted',
payload: result
});
},
specDone: function (result) {
result.duration = new Date() - this.lastSpecStartTime;
pushToQueue({
type: 'jasmine.specDone',
payload: result