tape-six 1.4.1 → 1.4.2
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/README.md +63 -0
- package/index.d.ts +6 -21
- package/package.json +1 -1
- package/src/TTYReporter.js +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,8 @@ Why `tape-six`? It was supposed to be named `tape6` but `npm` does not allow nam
|
|
|
16
16
|
to existing packages. Instead of eliminating name-squatting they force to use unintuitive and
|
|
17
17
|
unmemorable names. That's why all internal names, environment variables, and public names still use `tape6`.
|
|
18
18
|
|
|
19
|
+
See [examples in the wiki](https://github.com/uhop/tape-six/wiki/Examples).
|
|
20
|
+
|
|
19
21
|
## Rationale
|
|
20
22
|
|
|
21
23
|
Why another library? Working on projects written in modern JS (with modules) I found several problems
|
|
@@ -37,6 +39,66 @@ with existing unit test libraries:
|
|
|
37
39
|
- Integration with browser automation tools is supported for automated testing.
|
|
38
40
|
- Examples for such tools are [Playwright](https://playwright.dev/) and [Puppeteer](https://pptr.dev/) are provided.
|
|
39
41
|
|
|
42
|
+
## How it looks
|
|
43
|
+
|
|
44
|
+
_(The examples below show actual output of test functions. In real life, successful tests are usually hidden and only the final results are shown. Usually failed tests are shown with details and stack traces and the first fail stops testing to speed up the fail-fix cycle. All those details can be configured with settings.)_
|
|
45
|
+
|
|
46
|
+
Running a test file directly:
|
|
47
|
+
|
|
48
|
+
```txt
|
|
49
|
+
$ node tests/test-console.js
|
|
50
|
+
○ console test
|
|
51
|
+
log: log #1
|
|
52
|
+
✓ pass - 1.542ms
|
|
53
|
+
log: log #2
|
|
54
|
+
err: error #1
|
|
55
|
+
log: log #2a
|
|
56
|
+
✓ should be truthy - 1.725ms
|
|
57
|
+
log: log #3
|
|
58
|
+
err: error #2
|
|
59
|
+
✓ console test 2 0 - 4.747ms
|
|
60
|
+
♥️ tests: 1, asserts: 2, passed: 2, failed: 0, skipped: 0, todo: 0, time: 6.474ms
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Running a test suite:
|
|
64
|
+
|
|
65
|
+
```txt
|
|
66
|
+
$ npx tape6 tests/test-console.js tests/test-eval.js
|
|
67
|
+
○ FILE: /tests/test-console.js
|
|
68
|
+
○ console test
|
|
69
|
+
log: log #1
|
|
70
|
+
✓ pass - 0.338ms
|
|
71
|
+
log: log #2
|
|
72
|
+
err: error #1
|
|
73
|
+
log: log #2a
|
|
74
|
+
✓ should be truthy - 0.146ms
|
|
75
|
+
log: log #3
|
|
76
|
+
err: error #2
|
|
77
|
+
✓ console test 2 0 - 1.286ms
|
|
78
|
+
✓ FILE: /tests/test-console.js 2 0 - 7.411ms
|
|
79
|
+
○ FILE: /tests/test-eval.js
|
|
80
|
+
○ OK test
|
|
81
|
+
✓ 1 < 2 - 1.28ms
|
|
82
|
+
✓ a < b - 0.17ms
|
|
83
|
+
✓ a + b + c == "3three" - 0.13ms
|
|
84
|
+
✓ d.a < d.b - 0.105ms
|
|
85
|
+
✓ OK test 4 0 - 2.695ms
|
|
86
|
+
○ OK test with self
|
|
87
|
+
✓ internal check - 0.178ms
|
|
88
|
+
✓ 1 < 2 - 0.115ms
|
|
89
|
+
✓ OK test with self 2 0 - 0.55ms
|
|
90
|
+
✓ FILE: /tests/test-eval.js 6 0 - 5.756ms
|
|
91
|
+
♥️ tests: 5, asserts: 8, passed: 8, failed: 0, skipped: 0, todo: 0, time: 108.8ms
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
More colorful versions (click to see the original screenshots):
|
|
95
|
+
|
|
96
|
+
<img width="240" height="195" alt="image" src="https://github.com/user-attachments/assets/e10c631b-5035-4acb-b411-6af0e9b4041f" />
|
|
97
|
+
|
|
98
|
+
And:
|
|
99
|
+
|
|
100
|
+
<img width="240" height="329" alt="image" src="https://github.com/user-attachments/assets/f3d8ac65-9e6a-499d-837f-0271146da1de" />
|
|
101
|
+
|
|
40
102
|
## Docs
|
|
41
103
|
|
|
42
104
|
The documentation can be found in the [wiki](https://github.com/uhop/tape-six/wiki).
|
|
@@ -318,6 +380,7 @@ Test output can be controlled by flags. See [Supported flags](https://github.com
|
|
|
318
380
|
|
|
319
381
|
The most recent releases:
|
|
320
382
|
|
|
383
|
+
- 1.4.2 _Improved documentation._
|
|
321
384
|
- 1.4.1 _Added browser automation support._
|
|
322
385
|
- 1.4.0 _Added a high-level helper `OK()` for evaluating simple expressions._
|
|
323
386
|
- 1.3.5 _Minor improvements, better docs._
|
package/index.d.ts
CHANGED
|
@@ -348,21 +348,16 @@ export declare interface Test {
|
|
|
348
348
|
/**
|
|
349
349
|
* Returns a code as a string for evaluation that checks if the condition is truthy.
|
|
350
350
|
* @param condition - The JS condition to check as a string
|
|
351
|
-
* @param message -
|
|
351
|
+
* @param message - Optional message to display if the assertion fails
|
|
352
352
|
* @param options - Optional options object. `self` is the name of the tester argument, which should be used in the code. Default: `"t"`.
|
|
353
353
|
*/
|
|
354
|
-
OK(condition: string, message
|
|
354
|
+
OK(condition: string, message?: string, options?: {self?: string}): string;
|
|
355
355
|
/**
|
|
356
356
|
* Returns a code as a string for evaluation that checks if the condition is truthy.
|
|
357
357
|
* @param condition - The JS condition to check as a string
|
|
358
358
|
* @param options - Optional options object. `self` is the name of the tester argument, which should be used in the code. Default: `"t"`.
|
|
359
359
|
*/
|
|
360
360
|
OK(condition: string, options: {self?: string}): string;
|
|
361
|
-
/**
|
|
362
|
-
* Returns a code as a string for evaluation that checks if the condition is truthy.
|
|
363
|
-
* @param condition - The JS condition to check as a string
|
|
364
|
-
*/
|
|
365
|
-
OK(condition: string): string;
|
|
366
361
|
|
|
367
362
|
// aliases
|
|
368
363
|
|
|
@@ -624,40 +619,30 @@ export declare interface Test {
|
|
|
624
619
|
/**
|
|
625
620
|
* Returns a code as a string for evaluation that checks if the condition is truthy.
|
|
626
621
|
* @param condition - The JS condition to check as a string
|
|
627
|
-
* @param message -
|
|
622
|
+
* @param message - Optional message to display if the assertion fails
|
|
628
623
|
* @param options - Optional options object. `self` is the name of the tester argument, which should be used in the code. Default: `"t"`.
|
|
629
624
|
*/
|
|
630
|
-
TRUE(condition: string, message
|
|
625
|
+
TRUE(condition: string, message?: string, options?: {self?: string}): string;
|
|
631
626
|
/**
|
|
632
627
|
* Returns a code as a string for evaluation that checks if the condition is truthy.
|
|
633
628
|
* @param condition - The JS condition to check as a string
|
|
634
629
|
* @param options - Optional options object. `self` is the name of the tester argument, which should be used in the code. Default: `"t"`.
|
|
635
630
|
*/
|
|
636
631
|
TRUE(condition: string, options: {self?: string}): string;
|
|
637
|
-
/**
|
|
638
|
-
* Returns a code as a string for evaluation that checks if the condition is truthy.
|
|
639
|
-
* @param condition - The JS condition to check as a string
|
|
640
|
-
*/
|
|
641
|
-
TRUE(condition: string): string;
|
|
642
632
|
|
|
643
633
|
/**
|
|
644
634
|
* Returns a code as a string for evaluation that checks if the condition is truthy.
|
|
645
635
|
* @param condition - The JS condition to check as a string
|
|
646
|
-
* @param message -
|
|
636
|
+
* @param message - Optional message to display if the assertion fails
|
|
647
637
|
* @param options - Optional options object. `self` is the name of the tester argument, which should be used in the code. Default: `"t"`.
|
|
648
638
|
*/
|
|
649
|
-
ASSERT(condition: string, message
|
|
639
|
+
ASSERT(condition: string, message?: string, options?: {self?: string}): string;
|
|
650
640
|
/**
|
|
651
641
|
* Returns a code as a string for evaluation that checks if the condition is truthy.
|
|
652
642
|
* @param condition - The JS condition to check as a string
|
|
653
643
|
* @param options - Optional options object. `self` is the name of the tester argument, which should be used in the code. Default: `"t"`.
|
|
654
644
|
*/
|
|
655
645
|
ASSERT(condition: string, options: {self?: string}): string;
|
|
656
|
-
/**
|
|
657
|
-
* Returns a code as a string for evaluation that checks if the condition is truthy.
|
|
658
|
-
* @param condition - The JS condition to check as a string
|
|
659
|
-
*/
|
|
660
|
-
ASSERT(condition: string): string;
|
|
661
646
|
}
|
|
662
647
|
|
|
663
648
|
export declare interface Test {
|
package/package.json
CHANGED
package/src/TTYReporter.js
CHANGED
|
@@ -397,7 +397,7 @@ export class TTYReporter {
|
|
|
397
397
|
this.out(
|
|
398
398
|
this.success(' ' + this.successfulAsserts + ' ') +
|
|
399
399
|
this.failure(' ' + this.failedAsserts + ' ') +
|
|
400
|
-
(this.skippedAsserts ? this.skipped(' ' + this.skippedAsserts + ' ') : '')
|
|
400
|
+
(this.skippedAsserts ? this.skipped(' ' + this.skippedAsserts + ' ') : '', true)
|
|
401
401
|
);
|
|
402
402
|
}
|
|
403
403
|
makeState(state) {
|