mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
test runner: Pass single argument to append()
This makes the strings easier to read, and it simplifies `append()`. Also fix some lint errors: * Use `const` instead of `var`. * Convert `append()` to an arrow function. * Wrap long lines.
This commit is contained in:
parent
1f94ac5600
commit
064fcf8c00
1 changed files with 19 additions and 10 deletions
|
@ -71,7 +71,7 @@ $(() => {
|
||||||
: 'fast';
|
: 'fast';
|
||||||
|
|
||||||
stats.passes++;
|
stats.passes++;
|
||||||
append('->', '[green]PASSED[clear] :', test.title, ' ', test.duration, 'ms');
|
append(`-> [green]PASSED[clear] : ${test.title} ${test.duration} ms`);
|
||||||
});
|
});
|
||||||
|
|
||||||
runner.on('fail', (test, err) => {
|
runner.on('fail', (test, err) => {
|
||||||
|
@ -82,7 +82,7 @@ $(() => {
|
||||||
|
|
||||||
stats.failures++;
|
stats.failures++;
|
||||||
test.err = err;
|
test.err = err;
|
||||||
append('->', '[red]FAILED[clear] :', test.title, stringifyException(test.err));
|
append(`-> [red]FAILED[clear] : ${test.title} ${stringifyException(test.err)}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
runner.on('pending', (test) => {
|
runner.on('pending', (test) => {
|
||||||
|
@ -92,13 +92,12 @@ $(() => {
|
||||||
}, 60000 * 3);
|
}, 60000 * 3);
|
||||||
|
|
||||||
stats.pending++;
|
stats.pending++;
|
||||||
append('->', '[yellow]PENDING[clear]:', test.title);
|
append(`-> [yellow]PENDING[clear]: ${test.title}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
const $console = $('#console');
|
const $console = $('#console');
|
||||||
var level = 0;
|
var level = 0;
|
||||||
var append = function () {
|
const append = (text) => {
|
||||||
const text = Array.prototype.join.apply(arguments, [' ']);
|
|
||||||
const oldText = $console.text();
|
const oldText = $console.text();
|
||||||
|
|
||||||
let space = '';
|
let space = '';
|
||||||
|
@ -129,13 +128,23 @@ $(() => {
|
||||||
const minutes = Math.floor(stats.duration / 1000 / 60);
|
const minutes = Math.floor(stats.duration / 1000 / 60);
|
||||||
const seconds = Math.round((stats.duration / 1000) % 60); // chrome < 57 does not like this .toString().padStart("2","0");
|
const seconds = Math.round((stats.duration / 1000) % 60); // chrome < 57 does not like this .toString().padStart("2","0");
|
||||||
if (stats.tests === total) {
|
if (stats.tests === total) {
|
||||||
append('FINISHED -', stats.passes, 'tests passed,', stats.failures, 'tests failed,', stats.pending, ` pending, duration: ${minutes}:${seconds}`);
|
append(`FINISHED - ${stats.passes} tests passed, ${stats.failures} tests failed, ` +
|
||||||
|
`${stats.pending} pending, duration: ${minutes}:${seconds}`);
|
||||||
} else if (stats.tests > total) {
|
} else if (stats.tests > total) {
|
||||||
append('FINISHED - but more tests than planned returned', stats.passes, 'tests passed,', stats.failures, 'tests failed,', stats.pending, ` pending, duration: ${minutes}:${seconds}`);
|
append(`FINISHED - but more tests than planned returned ${stats.passes} tests passed, ` +
|
||||||
append(total, 'tests, but', stats.tests, 'returned. There is probably a problem with your async code or error handling, see https://github.com/mochajs/mocha/issues/1327');
|
`${stats.failures} tests failed, ${stats.pending} pending, ` +
|
||||||
|
`duration: ${minutes}:${seconds}`);
|
||||||
|
append(`${total} tests, but ${stats.tests} returned. ` +
|
||||||
|
'There is probably a problem with your async code or error handling, ' +
|
||||||
|
'see https://github.com/mochajs/mocha/issues/1327');
|
||||||
} else {
|
} else {
|
||||||
append('FINISHED - but not all tests returned', stats.passes, 'tests passed,', stats.failures, 'tests failed,', stats.pending, `tests pending, duration: ${minutes}:${seconds}`);
|
append(`FINISHED - but not all tests returned ${stats.passes} tests passed, ` +
|
||||||
append(total, 'tests, but only', stats.tests, 'returned. Check for failed before/beforeEach-hooks (no `test end` is called for them and subsequent tests of the same suite are skipped), see https://github.com/mochajs/mocha/pull/1043');
|
`${stats.failures} tests failed, ${stats.pending} tests pending, ` +
|
||||||
|
`duration: ${minutes}:${seconds}`);
|
||||||
|
append(`${total} tests, but only ${stats.tests} returned. ` +
|
||||||
|
'Check for failed before/beforeEach-hooks (no `test end` is called for them ' +
|
||||||
|
'and subsequent tests of the same suite are skipped), ' +
|
||||||
|
'see https://github.com/mochajs/mocha/pull/1043');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue