@locustjs/test 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +9 -10
- package/index.esm.js +12 -13
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -568,7 +568,7 @@ class TestRunner {
|
|
|
568
568
|
}
|
|
569
569
|
return _test;
|
|
570
570
|
}).filter(test => test instanceof Test).map((test, i) => this._runSingle(test, onProgress, i));
|
|
571
|
-
Promise.all(_tests).then(_ => res()).catch(ex => {
|
|
571
|
+
Promise.all(_tests).then(_ => res(this.result)).catch(ex => {
|
|
572
572
|
this._errors.push({
|
|
573
573
|
err: new Exception({
|
|
574
574
|
message: `not all tests succeeded. check errors.`,
|
|
@@ -577,7 +577,7 @@ class TestRunner {
|
|
|
577
577
|
innerException: ex
|
|
578
578
|
})
|
|
579
579
|
});
|
|
580
|
-
res();
|
|
580
|
+
res(this.result);
|
|
581
581
|
});
|
|
582
582
|
} else {
|
|
583
583
|
this._errors.push({
|
|
@@ -587,7 +587,7 @@ class TestRunner {
|
|
|
587
587
|
status: 'invalid-tests'
|
|
588
588
|
})
|
|
589
589
|
});
|
|
590
|
-
res();
|
|
590
|
+
res(this.result);
|
|
591
591
|
}
|
|
592
592
|
} else {
|
|
593
593
|
this._errors.push({
|
|
@@ -597,7 +597,7 @@ class TestRunner {
|
|
|
597
597
|
status: 'no-tests'
|
|
598
598
|
})
|
|
599
599
|
});
|
|
600
|
-
res();
|
|
600
|
+
res(this.result);
|
|
601
601
|
}
|
|
602
602
|
});
|
|
603
603
|
}
|
|
@@ -606,18 +606,17 @@ class TestRunner {
|
|
|
606
606
|
}
|
|
607
607
|
report(detailed) {
|
|
608
608
|
let time = 0;
|
|
609
|
-
console.log('Finished.\n
|
|
609
|
+
console.log('Finished.\n');
|
|
610
610
|
for (let i = 0; i < this._results.length; i++) {
|
|
611
611
|
const result = this._results[i];
|
|
612
612
|
if (detailed) {
|
|
613
|
-
let message;
|
|
613
|
+
let message = '\n';
|
|
614
614
|
if (result.success) {
|
|
615
|
-
message
|
|
615
|
+
message += `${i + 1}. \x1b[${ConsoleColors.ForeColor.White}m${result.test}: \x1b[${ConsoleColors.ForeColor.Green}m passed ${ConsoleColors.Modifier.Reset} (${this._getTime(result.time)})`;
|
|
616
616
|
} else {
|
|
617
|
-
message
|
|
617
|
+
message += `${i + 1}. \x1b[${ConsoleColors.ForeColor.White}m${result.test}: \x1b[${ConsoleColors.ForeColor.Red}m failed ${ConsoleColors.Modifier.Reset} (${this._getTime(result.time)})`;
|
|
618
618
|
message += '\n';
|
|
619
619
|
message += `\x1b[${ConsoleColors.ForeColor.White}m${result.err.code}: ${result.err.toString()} ${ConsoleColors.Modifier.Reset}`;
|
|
620
|
-
message += '\n';
|
|
621
620
|
}
|
|
622
621
|
console.log(message);
|
|
623
622
|
}
|
|
@@ -633,7 +632,7 @@ class TestRunner {
|
|
|
633
632
|
}
|
|
634
633
|
}
|
|
635
634
|
}
|
|
636
|
-
const text = (detailed ? '\n' : '') +
|
|
635
|
+
const text = (detailed ? '\n' : '') + `Tests: ${this._passed + this._failed}` + '\n' + `Time: ${time / 1000} sec` + '\n\n' + (this._passed > 0 ? `\x1b[${ConsoleColors.ForeColor.Green}m ${this._passed} tests passed${ConsoleColors.Modifier.Reset}` : '0 tests passed') + ', ' + (this._failed > 0 ? `\x1b[${ConsoleColors.ForeColor.Red}m ${this._failed} tests failed${ConsoleColors.Modifier.Reset}` : '0 tests failed') + '\n';
|
|
637
636
|
console.log(text);
|
|
638
637
|
}
|
|
639
638
|
log(filename) {
|
package/index.esm.js
CHANGED
|
@@ -384,20 +384,20 @@ class TestRunner {
|
|
|
384
384
|
.filter(test => (test instanceof Test))
|
|
385
385
|
.map((test, i) => this._runSingle(test, onProgress, i));
|
|
386
386
|
|
|
387
|
-
Promise.all(_tests).then(_ => res()).catch(ex => {
|
|
387
|
+
Promise.all(_tests).then(_ => res(this.result)).catch(ex => {
|
|
388
388
|
this._errors.push({ err: new Exception({ message: `not all tests succeeded. check errors.`, code: 1503, status: 'partial-finished', innerException: ex }) });
|
|
389
389
|
|
|
390
|
-
res();
|
|
390
|
+
res(this.result);
|
|
391
391
|
});
|
|
392
392
|
} else {
|
|
393
393
|
this._errors.push({ err: new Exception({ message: `invalid tests. expected array or a single test.`, code: 1502, status: 'invalid-tests' }) });
|
|
394
394
|
|
|
395
|
-
res();
|
|
395
|
+
res(this.result);
|
|
396
396
|
}
|
|
397
397
|
} else {
|
|
398
398
|
this._errors.push({ err: new Exception({ message: `no tests given to be ran.`, code: 1501, status: 'no-tests' }) });
|
|
399
399
|
|
|
400
|
-
res();
|
|
400
|
+
res(this.result);
|
|
401
401
|
}
|
|
402
402
|
})
|
|
403
403
|
}
|
|
@@ -407,21 +407,20 @@ class TestRunner {
|
|
|
407
407
|
report(detailed) {
|
|
408
408
|
let time = 0;
|
|
409
409
|
|
|
410
|
-
console.log('Finished.\n
|
|
410
|
+
console.log('Finished.\n');
|
|
411
411
|
|
|
412
412
|
for (let i = 0; i < this._results.length; i++) {
|
|
413
413
|
const result = this._results[i];
|
|
414
414
|
|
|
415
415
|
if (detailed) {
|
|
416
|
-
let message;
|
|
416
|
+
let message = '\n';
|
|
417
417
|
|
|
418
418
|
if (result.success) {
|
|
419
|
-
message
|
|
419
|
+
message += `${i + 1}. \x1b[${ConsoleColors.ForeColor.White}m${result.test}: \x1b[${ConsoleColors.ForeColor.Green}m passed ${ConsoleColors.Modifier.Reset} (${this._getTime(result.time)})`
|
|
420
420
|
} else {
|
|
421
|
-
message
|
|
421
|
+
message += `${i + 1}. \x1b[${ConsoleColors.ForeColor.White}m${result.test}: \x1b[${ConsoleColors.ForeColor.Red}m failed ${ConsoleColors.Modifier.Reset} (${this._getTime(result.time)})`;
|
|
422
422
|
message += '\n';
|
|
423
423
|
message += `\x1b[${ConsoleColors.ForeColor.White}m${result.err.code}: ${result.err.toString()} ${ConsoleColors.Modifier.Reset}`;
|
|
424
|
-
message += '\n';
|
|
425
424
|
}
|
|
426
425
|
|
|
427
426
|
console.log(message);
|
|
@@ -443,13 +442,13 @@ class TestRunner {
|
|
|
443
442
|
}
|
|
444
443
|
|
|
445
444
|
const text = (detailed ? '\n': '') +
|
|
446
|
-
(this._failed > 0 ? `\x1b[${ConsoleColors.ForeColor.Red}m ${this._failed} tests failed ${ConsoleColors.Modifier.Reset}` : '0 tests failed') +
|
|
447
|
-
', ' +
|
|
448
|
-
(this._passed > 0 ? `\x1b[${ConsoleColors.ForeColor.Green}m ${this._passed} tests passed ${ConsoleColors.Modifier.Reset}` : '0 tests passed') +
|
|
449
|
-
'\n' +
|
|
450
445
|
`Tests: ${this._passed + this._failed}` +
|
|
451
446
|
'\n' +
|
|
452
447
|
`Time: ${time / 1000} sec` +
|
|
448
|
+
'\n\n' +
|
|
449
|
+
(this._passed > 0 ? `\x1b[${ConsoleColors.ForeColor.Green}m ${this._passed} tests passed${ConsoleColors.Modifier.Reset}` : '0 tests passed') +
|
|
450
|
+
', ' +
|
|
451
|
+
(this._failed > 0 ? `\x1b[${ConsoleColors.ForeColor.Red}m ${this._failed} tests failed${ConsoleColors.Modifier.Reset}` : '0 tests failed') +
|
|
453
452
|
'\n';
|
|
454
453
|
|
|
455
454
|
console.log(text);
|