@locustjs/test 1.1.4 → 1.1.6
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 +8 -9
- package/index.esm.js +12 -12
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -433,9 +433,9 @@ class Test {
|
|
|
433
433
|
}
|
|
434
434
|
run() {
|
|
435
435
|
return new Promise(res => {
|
|
436
|
+
const start = new Date();
|
|
436
437
|
if (isFunction(this.fn)) {
|
|
437
438
|
try {
|
|
438
|
-
const start = new Date();
|
|
439
439
|
const _result = this.fn(expect);
|
|
440
440
|
if (_result && isFunction(_result.then)) {
|
|
441
441
|
_result.then(result => {
|
|
@@ -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,14 +632,14 @@ 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) {
|
|
640
639
|
const content = JSON.stringify({
|
|
641
640
|
results: this._results,
|
|
642
641
|
errors: this._errors
|
|
643
|
-
});
|
|
642
|
+
}, null, '\t');
|
|
644
643
|
if (filename == null) {
|
|
645
644
|
const d = new Date();
|
|
646
645
|
const year = d.getFullYear().toString().padStart(4, '0');
|
|
@@ -649,7 +648,7 @@ class TestRunner {
|
|
|
649
648
|
const hours = d.getHours().toString().padStart(2, '0');
|
|
650
649
|
const minutes = d.getMinutes().toString().padStart(2, '0');
|
|
651
650
|
const seconds = d.getSeconds().toString().padStart(2, '0');
|
|
652
|
-
filename = `test-${year}-${month}-${day}-${hours}${minutes}${seconds}.
|
|
651
|
+
filename = `test-${year}-${month}-${day}-${hours}${minutes}${seconds}.json`;
|
|
653
652
|
}
|
|
654
653
|
const filepath = path.join(process.cwd(), filename);
|
|
655
654
|
try {
|
package/index.esm.js
CHANGED
|
@@ -282,9 +282,10 @@ class Test {
|
|
|
282
282
|
}
|
|
283
283
|
run() {
|
|
284
284
|
return new Promise(res => {
|
|
285
|
+
const start = new Date();
|
|
286
|
+
|
|
285
287
|
if (isFunction(this.fn)) {
|
|
286
288
|
try {
|
|
287
|
-
const start = new Date();
|
|
288
289
|
const _result = this.fn(expect);
|
|
289
290
|
|
|
290
291
|
if (_result && isFunction(_result.then)) {
|
|
@@ -406,21 +407,20 @@ class TestRunner {
|
|
|
406
407
|
report(detailed) {
|
|
407
408
|
let time = 0;
|
|
408
409
|
|
|
409
|
-
console.log('Finished.\n
|
|
410
|
+
console.log('Finished.\n');
|
|
410
411
|
|
|
411
412
|
for (let i = 0; i < this._results.length; i++) {
|
|
412
413
|
const result = this._results[i];
|
|
413
414
|
|
|
414
415
|
if (detailed) {
|
|
415
|
-
let message;
|
|
416
|
+
let message = '\n';
|
|
416
417
|
|
|
417
418
|
if (result.success) {
|
|
418
|
-
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)})`
|
|
419
420
|
} else {
|
|
420
|
-
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)})`;
|
|
421
422
|
message += '\n';
|
|
422
423
|
message += `\x1b[${ConsoleColors.ForeColor.White}m${result.err.code}: ${result.err.toString()} ${ConsoleColors.Modifier.Reset}`;
|
|
423
|
-
message += '\n';
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
console.log(message);
|
|
@@ -442,13 +442,13 @@ class TestRunner {
|
|
|
442
442
|
}
|
|
443
443
|
|
|
444
444
|
const text = (detailed ? '\n': '') +
|
|
445
|
-
(this._failed > 0 ? `\x1b[${ConsoleColors.ForeColor.Red}m ${this._failed} tests failed ${ConsoleColors.Modifier.Reset}` : '0 tests failed') +
|
|
446
|
-
', ' +
|
|
447
|
-
(this._passed > 0 ? `\x1b[${ConsoleColors.ForeColor.Green}m ${this._passed} tests passed ${ConsoleColors.Modifier.Reset}` : '0 tests passed') +
|
|
448
|
-
'\n' +
|
|
449
445
|
`Tests: ${this._passed + this._failed}` +
|
|
450
446
|
'\n' +
|
|
451
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') +
|
|
452
452
|
'\n';
|
|
453
453
|
|
|
454
454
|
console.log(text);
|
|
@@ -457,7 +457,7 @@ class TestRunner {
|
|
|
457
457
|
const content = JSON.stringify({
|
|
458
458
|
results: this._results,
|
|
459
459
|
errors: this._errors
|
|
460
|
-
});
|
|
460
|
+
}, null, '\t');
|
|
461
461
|
|
|
462
462
|
if (filename == null) {
|
|
463
463
|
const d = new Date();
|
|
@@ -469,7 +469,7 @@ class TestRunner {
|
|
|
469
469
|
const minutes = d.getMinutes().toString().padStart(2, '0');
|
|
470
470
|
const seconds = d.getSeconds().toString().padStart(2, '0');
|
|
471
471
|
|
|
472
|
-
filename = `test-${year}-${month}-${day}-${hours}${minutes}${seconds}.
|
|
472
|
+
filename = `test-${year}-${month}-${day}-${hours}${minutes}${seconds}.json`;
|
|
473
473
|
}
|
|
474
474
|
|
|
475
475
|
const filepath = path.join(process.cwd(), filename);
|