@reporters/testwatch 1.3.0 → 1.3.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/index.js +1 -1
- package/package.json +5 -1
- package/CHANGELOG.md +0 -50
- package/assets/cli.gif +0 -0
- package/assets/cli.gif.yml +0 -185
- package/tests/fixtures/index.test.js +0 -9
- package/tests/fixtures/j.spec.js +0 -9
- package/tests/fixtures/not-test.js +0 -6
- package/tests/index.test.js +0 -278
package/index.js
CHANGED
|
@@ -81,7 +81,7 @@ class REPL {
|
|
|
81
81
|
async function* (source) {
|
|
82
82
|
for await (const data of source) {
|
|
83
83
|
yield data;
|
|
84
|
-
if (data.type === 'test:start'
|
|
84
|
+
if (drained && (data.type === 'test:start' || data.type === 'test:enqueue')) {
|
|
85
85
|
this.#clear();
|
|
86
86
|
drained = false;
|
|
87
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reporters/testwatch",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "An interactive repl for `node:test`",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node:test",
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
"reporters"
|
|
10
10
|
],
|
|
11
11
|
"bin": "./index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"./index.js",
|
|
14
|
+
"nodeVersion.js"
|
|
15
|
+
],
|
|
12
16
|
"scripts": {
|
|
13
17
|
"test": "node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=../github/index.js --test-reporter-destination=stdout --test tests/index.test.js",
|
|
14
18
|
"test:watch": "testwatch tests/index"
|
package/CHANGELOG.md
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## [1.3.0](https://github.com/MoLow/reporters/compare/testwatch-v1.2.1...testwatch-v1.3.0) (2023-07-05)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
### Features
|
|
7
|
-
|
|
8
|
-
* publish with provenance ([6ee1e46](https://github.com/MoLow/reporters/commit/6ee1e46040329edeb0f40f753093b6952984f001))
|
|
9
|
-
|
|
10
|
-
## [1.2.1](https://github.com/MoLow/reporters/compare/testwatch-v1.2.0...testwatch-v1.2.1) (2023-07-02)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
### Bug Fixes
|
|
14
|
-
|
|
15
|
-
* clear screen before tests ([3d3f67c](https://github.com/MoLow/reporters/commit/3d3f67cddd7047c857e001066021933eb1381ec3))
|
|
16
|
-
|
|
17
|
-
## [1.2.0](https://github.com/MoLow/reporters/compare/testwatch-v1.1.1...testwatch-v1.2.0) (2023-06-19)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
### Features
|
|
21
|
-
|
|
22
|
-
* add test:watch script ([4357fbd](https://github.com/MoLow/reporters/commit/4357fbde5f337cfd39226497f8ce0f6760f8a62c))
|
|
23
|
-
* change default file filter ([5968235](https://github.com/MoLow/reporters/commit/596823529cd9a86e5eeada0523825fa215e49efe))
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
### Bug Fixes
|
|
27
|
-
|
|
28
|
-
* don't exit when no tests on initial run ([66bcc2b](https://github.com/MoLow/reporters/commit/66bcc2bc6436b544900cfbceb4bbfb0d93973490))
|
|
29
|
-
|
|
30
|
-
## [1.1.1](https://github.com/MoLow/reporters/compare/testwatch-v1.1.0...testwatch-v1.1.1) (2023-06-12)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
### Bug Fixes
|
|
34
|
-
|
|
35
|
-
* increas maximum listeners of event emitters ([b16d2ab](https://github.com/MoLow/reporters/commit/b16d2ab3b55554e1aaa9b9ca2222254bac364803))
|
|
36
|
-
* support partial file name filter ([2b3f0ab](https://github.com/MoLow/reporters/commit/2b3f0abe0be37450c7b9189667ad47d4d39a4252))
|
|
37
|
-
|
|
38
|
-
## [1.1.0](https://github.com/MoLow/reporters/compare/testwatch-v1.0.0...testwatch-v1.1.0) (2023-06-08)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### Features
|
|
42
|
-
|
|
43
|
-
* fix @reporters/bail docs ([32fd66b](https://github.com/MoLow/reporters/commit/32fd66bdf788a2d6067bac72cee9fbc50b2d76e3))
|
|
44
|
-
|
|
45
|
-
## 1.0.0 (2023-06-08)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
### Features
|
|
49
|
-
|
|
50
|
-
* add @reporters/repl package ([b66b525](https://github.com/MoLow/reporters/commit/b66b525c78e93e96d04b19a2e846ab040078ace7))
|
package/assets/cli.gif
DELETED
|
Binary file
|
package/assets/cli.gif.yml
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
# The configurations that used for the recording, feel free to edit them
|
|
2
|
-
config:
|
|
3
|
-
|
|
4
|
-
# Specify a command to be executed
|
|
5
|
-
# like `/bin/bash -l`, `ls`, or any other commands
|
|
6
|
-
# the default is bash for Linux
|
|
7
|
-
# or powershell.exe for Windows
|
|
8
|
-
command: bash -l
|
|
9
|
-
|
|
10
|
-
# Specify the current working directory path
|
|
11
|
-
# the default is the current working directory path
|
|
12
|
-
cwd: ~
|
|
13
|
-
|
|
14
|
-
# Export additional ENV variables
|
|
15
|
-
env:
|
|
16
|
-
recording: true
|
|
17
|
-
|
|
18
|
-
# Explicitly set the number of columns
|
|
19
|
-
# or use `auto` to take the current
|
|
20
|
-
# number of columns of your shell
|
|
21
|
-
cols: 166
|
|
22
|
-
|
|
23
|
-
# Explicitly set the number of rows
|
|
24
|
-
# or use `auto` to take the current
|
|
25
|
-
# number of rows of your shell
|
|
26
|
-
rows: 23
|
|
27
|
-
|
|
28
|
-
# Amount of times to repeat GIF
|
|
29
|
-
# If value is -1, play once
|
|
30
|
-
# If value is 0, loop indefinitely
|
|
31
|
-
# If value is a positive number, loop n times
|
|
32
|
-
repeat: 0
|
|
33
|
-
|
|
34
|
-
# Quality
|
|
35
|
-
# 1 - 100
|
|
36
|
-
quality: 100
|
|
37
|
-
|
|
38
|
-
# Delay between frames in ms
|
|
39
|
-
# If the value is `auto` use the actual recording delays
|
|
40
|
-
frameDelay: auto
|
|
41
|
-
|
|
42
|
-
# Maximum delay between frames in ms
|
|
43
|
-
# Ignored if the `frameDelay` isn't set to `auto`
|
|
44
|
-
# Set to `auto` to prevent limiting the max idle time
|
|
45
|
-
maxIdleTime: 2000
|
|
46
|
-
|
|
47
|
-
# The surrounding frame box
|
|
48
|
-
# The `type` can be null, window, floating, or solid`
|
|
49
|
-
# To hide the title use the value null
|
|
50
|
-
# Don't forget to add a backgroundColor style with a null as type
|
|
51
|
-
frameBox:
|
|
52
|
-
type: floating
|
|
53
|
-
title: Terminalizer
|
|
54
|
-
style:
|
|
55
|
-
border: 0px black solid
|
|
56
|
-
boxShadow: none
|
|
57
|
-
margin: 0px
|
|
58
|
-
|
|
59
|
-
# Add a watermark image to the rendered gif
|
|
60
|
-
# You need to specify an absolute path for
|
|
61
|
-
# the image on your machine or a URL, and you can also
|
|
62
|
-
# add your own CSS styles
|
|
63
|
-
watermark:
|
|
64
|
-
imagePath: null
|
|
65
|
-
style:
|
|
66
|
-
position: absolute
|
|
67
|
-
right: 15px
|
|
68
|
-
bottom: 15px
|
|
69
|
-
width: 100px
|
|
70
|
-
opacity: 0.9
|
|
71
|
-
|
|
72
|
-
# Cursor style can be one of
|
|
73
|
-
# `block`, `underline`, or `bar`
|
|
74
|
-
cursorStyle: block
|
|
75
|
-
|
|
76
|
-
# Font family
|
|
77
|
-
# You can use any font that is installed on your machine
|
|
78
|
-
# in CSS-like syntax
|
|
79
|
-
fontFamily: "Monaco, Lucida Console, Ubuntu Mono, Monospace"
|
|
80
|
-
|
|
81
|
-
# The size of the font
|
|
82
|
-
fontSize: 12
|
|
83
|
-
|
|
84
|
-
# The height of lines
|
|
85
|
-
lineHeight: 1
|
|
86
|
-
|
|
87
|
-
# The spacing between letters
|
|
88
|
-
letterSpacing: 0
|
|
89
|
-
|
|
90
|
-
# Theme
|
|
91
|
-
theme:
|
|
92
|
-
background: "transparent"
|
|
93
|
-
foreground: "#afafaf"
|
|
94
|
-
cursor: "#c7c7c7"
|
|
95
|
-
black: "#232628"
|
|
96
|
-
red: "#fc4384"
|
|
97
|
-
green: "#b3e33b"
|
|
98
|
-
yellow: "#ffa727"
|
|
99
|
-
blue: "#75dff2"
|
|
100
|
-
magenta: "#ae89fe"
|
|
101
|
-
cyan: "#708387"
|
|
102
|
-
white: "#d5d5d0"
|
|
103
|
-
brightBlack: "#626566"
|
|
104
|
-
brightRed: "#ff7fac"
|
|
105
|
-
brightGreen: "#c8ed71"
|
|
106
|
-
brightYellow: "#ebdf86"
|
|
107
|
-
brightBlue: "#75dff2"
|
|
108
|
-
brightMagenta: "#ae89fe"
|
|
109
|
-
brightCyan: "#b1c6ca"
|
|
110
|
-
brightWhite: "#f9f9f4"
|
|
111
|
-
|
|
112
|
-
# Records, feel free to edit them
|
|
113
|
-
records:
|
|
114
|
-
- delay: 0
|
|
115
|
-
content: '$ '
|
|
116
|
-
- delay: 651
|
|
117
|
-
content: testwatch
|
|
118
|
-
- delay: 713
|
|
119
|
-
content: "\r\n"
|
|
120
|
-
- delay: 688
|
|
121
|
-
content: "\ec▶ testwatch\r\n \e[32m✔ should run all tests on initialization \e[90m(445.057167ms)\e[39m\e[39m\r\n \e[32m✔ should handle CTR + C \e[90m(443.270375ms)\e[39m\e[39m\r\n"
|
|
122
|
-
- delay: 123
|
|
123
|
-
content: " \e[32m✔ should handle CTR + D \e[90m(566.298666ms)\e[39m\e[39m\r\n"
|
|
124
|
-
- delay: 102
|
|
125
|
-
content: " \e[32m✔ should run all tests on \"a\" \e[90m(668.500542ms)\e[39m\e[39m\r\n"
|
|
126
|
-
- delay: 11
|
|
127
|
-
content: " \e[32m✔ should run all tests on Enter \e[90m(678.704958ms)\e[39m\e[39m\r\n \e[32m✔ should show full menu on \"w\" after running tests \e[90m(638.493708ms)\e[39m\e[39m\r\n"
|
|
128
|
-
- delay: 25
|
|
129
|
-
content: " ▶ filters\r\n \e[32m✔ should filter tests on \"t\" \e[90m(701.858542ms)\e[39m\e[39m\r\n \e[32m✔ should filter files on \"p\" \e[90m(668.653625ms)\e[39m\e[39m\r\n"
|
|
130
|
-
- delay: 201
|
|
131
|
-
content: " \e[32m✔ should filter tests and files togetheer \e[90m(902.623166ms)\e[39m\e[39m\r\n \e[32m✔ should mention when no files found \e[90m(669.483333ms)\e[39m\e[39m\r\n"
|
|
132
|
-
- delay: 234
|
|
133
|
-
content: " \e[32m✔ should clear filters on \"c\" \e[90m(1136.047417ms)\e[39m\e[39m\r\n \e[32m✔ prompt ESC should preserve previous state \e[90m(1101.547958ms)\e[39m\e[39m\r\n \e[32m✔ backspace shoud remove last character \e[90m(627.751292ms)\e[39m\e[39m\r\n \e[32m▶ \e[39mfilters \e[90m(1138.54675ms)\e[39m\r\n\r\n\e[32m▶ \e[39mtestwatch \e[90m(1143.543416ms)\e[39m\r\n\r\n"
|
|
134
|
-
- delay: 6
|
|
135
|
-
content: "\e[32m✔ j - sum \e[90m(0.458875ms)\e[39m\e[39m\r\n\e[32m✔ j - subtraction \e[90m(0.160625ms)\e[39m\e[39m\r\n\e[32m✔ index - sum \e[90m(0.454875ms)\e[39m\e[39m\r\n\e[32m✔ index - subtraction \e[90m(0.128083ms)\e[39m\e[39m\r\n\r\n\e[1mREPL Usage\e[22m\r\n\e[90m › Press \e[37m\e[1ma\e[22m\e[39m\e[90m to run all tests.\e[39m\r\n\e[90m › Press \e[37m\e[1mp\e[22m\e[39m\e[90m to filter by a file name pattern.\e[39m\r\n\e[90m › Press \e[37m\e[1mt\e[22m\e[39m\e[90m to filter by a test name pattern.\e[39m\r\n\e[90m › Press \e[37m\e[1mq\e[22m\e[39m\e[90m to quit.\e[39m\r\n\e[90m › Press \e[37m\e[1mEnter\e[22m\e[39m\e[90m to trigger a test run.\e[39m\r\n"
|
|
136
|
-
- delay: 1523
|
|
137
|
-
content: "\ec\r\n\e[1mFilter File\e[22m\r\n\e[90m › Press \e[37m\e[1mEnter\e[22m\e[39m\e[90m to filter by a file name pattern.\e[39m\r\n\e[90m › Press \e[37m\e[1mEsc\e[22m\e[39m\e[90m to exit pattern mode.\e[39m\r\n\e[90m\e[39m\r\n\e[90m pattern › \e[39m"
|
|
138
|
-
- delay: 1000
|
|
139
|
-
content: tests/fixtures/**
|
|
140
|
-
- delay: 500
|
|
141
|
-
content: "\ec"
|
|
142
|
-
- delay: 78
|
|
143
|
-
content: "\ec\e[32m✔ j - sum \e[90m(0.430167ms)\e[39m\e[39m\r\n\e[32m✔ j - subtraction \e[90m(0.127208ms)\e[39m\e[39m\r\n"
|
|
144
|
-
- delay: 5
|
|
145
|
-
content: "\e[32m✔ index - sum \e[90m(0.430083ms)\e[39m\e[39m\r\n\e[32m✔ index - subtraction \e[90m(0.124042ms)\e[39m\e[39m\r\n\e[90m\e[39m\r\n\e[90m\e[37m\e[1mREPL Usage\e[22m\e[39m\e[90m: Press \e[37m\e[1mw\e[22m\e[39m\e[90m to show more.\e[39m"
|
|
146
|
-
- delay: 1000
|
|
147
|
-
content: "\r\n\e[1A\e[2K\e[1A\e[2K\r\n\e[37m\e[1mActive Filters:\e[22m\e[39m file name \e[90m**/\e[39m\e[33mtests/fixtures/**\e[39m\e[90m.*\e[39m\r\n\r\n\e[1mREPL Usage\e[22m\r\n\e[90m › Press \e[37m\e[1mc\e[22m\e[39m\e[90m to clear the filters.\e[39m\r\n\e[90m › Press \e[37m\e[1ma\e[22m\e[39m\e[90m to run all tests.\e[39m\r\n\e[90m › Press \e[37m\e[1mp\e[22m\e[39m\e[90m to filter by a file name pattern.\e[39m\r\n\e[90m › Press \e[37m\e[1mt\e[22m\e[39m\e[90m to filter by a test name pattern.\e[39m\r\n\e[90m › Press \e[37m\e[1mq\e[22m\e[39m\e[90m to quit.\e[39m\r\n\e[90m › Press \e[37m\e[1mEnter\e[22m\e[39m\e[90m to trigger a test run.\e[39m\r\n"
|
|
148
|
-
- delay: 1000
|
|
149
|
-
content: "\ec\r\n\e[37m\e[1mActive Filters:\e[22m\e[39m file name \e[90m**/\e[39m\e[33mtests/fixtures/**\e[39m\e[90m.*\e[39m\r\n\r\n\e[1mFilter Test\e[22m\r\n\e[90m › Press \e[37m\e[1mEnter\e[22m\e[39m\e[90m to filter by a test name pattern.\e[39m\r\n\e[90m › Press \e[37m\e[1mEsc\e[22m\e[39m\e[90m to exit pattern mode.\e[39m\r\n\e[90m\e[39m\r\n\e[90m pattern › \e[39m"
|
|
150
|
-
- delay: 1000
|
|
151
|
-
content: sum
|
|
152
|
-
- delay: 1000
|
|
153
|
-
content: "\ec"
|
|
154
|
-
- delay: 68
|
|
155
|
-
content: "\ec\e[32m✔ j - sum \e[90m(0.44275ms)\e[39m\e[39m\r\n\e[90m﹣ j - subtraction \e[90m(0.12475ms)\e[39m # SKIP\e[39m\r\n"
|
|
156
|
-
- delay: 5
|
|
157
|
-
content: "\e[32m✔ index - sum \e[90m(0.4315ms)\e[39m\e[39m\r\n\e[90m﹣ index - subtraction \e[90m(0.12175ms)\e[39m # SKIP\e[39m\r\n\e[90m\e[39m\r\n\e[90m\e[37m\e[1mREPL Usage\e[22m\e[39m\e[90m: Press \e[37m\e[1mw\e[22m\e[39m\e[90m to show more.\e[39m"
|
|
158
|
-
- delay: 1000
|
|
159
|
-
content: "\r\n\e[1A\e[2K\e[1A\e[2K\r\n\e[37m\e[1mActive Filters:\e[22m\e[39m file name \e[90m**/\e[39m\e[33mtests/fixtures/**\e[39m\e[90m.*\e[39m, test name \e[33m/sum/\e[39m\r\n\r\n\e[1mREPL Usage\e[22m\r\n\e[90m › Press \e[37m\e[1mc\e[22m\e[39m\e[90m to clear the filters.\e[39m\r\n\e[90m › Press \e[37m\e[1ma\e[22m\e[39m\e[90m to run all tests.\e[39m\r\n\e[90m › Press \e[37m\e[1mp\e[22m\e[39m\e[90m to filter by a file name pattern.\e[39m\r\n\e[90m › Press \e[37m\e[1mt\e[22m\e[39m\e[90m to filter by a test name pattern.\e[39m\r\n\e[90m › Press \e[37m\e[1mq\e[22m\e[39m\e[90m to quit.\e[39m\r\n\e[90m › Press \e[37m\e[1mEnter\e[22m\e[39m\e[90m to trigger a test run.\e[39m\r\n"
|
|
160
|
-
- delay: 1000
|
|
161
|
-
content: "\ec\e[32m✔ j - sum \e[90m(0.422125ms)\e[39m\e[39m\r\n\e[90m﹣ j - subtraction \e[90m(0.123084ms)\e[39m # SKIP\e[39m\r\n"
|
|
162
|
-
- delay: 7
|
|
163
|
-
content: "\e[32m✔ index - sum \e[90m(0.424667ms)\e[39m\e[39m\r\n\e[90m﹣ index - subtraction \e[90m(0.119458ms)\e[39m # SKIP\e[39m\r\n\e[90m\e[39m\r\n\e[90m\e[37m\e[1mREPL Usage\e[22m\e[39m\e[90m: Press \e[37m\e[1mw\e[22m\e[39m\e[90m to show more.\e[39m"
|
|
164
|
-
- delay: 1000
|
|
165
|
-
content: "\r\n\e[1A\e[2K\e[1A\e[2K\r\n\e[37m\e[1mActive Filters:\e[22m\e[39m file name \e[90m**/\e[39m\e[33mtests/fixtures/**\e[39m\e[90m.*\e[39m, test name \e[33m/sum/\e[39m\r\n\r\n\e[1mREPL Usage\e[22m\r\n\e[90m › Press \e[37m\e[1mc\e[22m\e[39m\e[90m to clear the filters.\e[39m\r\n\e[90m › Press \e[37m\e[1ma\e[22m\e[39m\e[90m to run all tests.\e[39m\r\n\e[90m › Press \e[37m\e[1mp\e[22m\e[39m\e[90m to filter by a file name pattern.\e[39m\r\n\e[90m › Press \e[37m\e[1mt\e[22m\e[39m\e[90m to filter by a test name pattern.\e[39m\r\n\e[90m › Press \e[37m\e[1mq\e[22m\e[39m\e[90m to quit.\e[39m\r\n\e[90m › Press \e[37m\e[1mEnter\e[22m\e[39m\e[90m to trigger a test run.\e[39m\r\n"
|
|
166
|
-
- delay: 1000
|
|
167
|
-
content: "\ec▶ testwatch\r\n \e[32m✔ should run all tests on initialization \e[90m(377.157833ms)\e[39m\e[39m\r\n"
|
|
168
|
-
- delay: 45
|
|
169
|
-
content: " \e[32m✔ should handle CTR + C \e[90m(421.077417ms)\e[39m\e[39m\r\n"
|
|
170
|
-
- delay: 17
|
|
171
|
-
content: " \e[32m✔ should handle CTR + D \e[90m(437.436042ms)\e[39m\e[39m\r\n"
|
|
172
|
-
- delay: 190
|
|
173
|
-
content: " \e[32m✔ should run all tests on \"a\" \e[90m(626.754917ms)\e[39m\e[39m\r\n \e[32m✔ should run all tests on Enter \e[90m(628.015583ms)\e[39m\e[39m\r\n"
|
|
174
|
-
- delay: 25
|
|
175
|
-
content: " \e[32m✔ should show full menu on \"w\" after running tests \e[90m(652.595ms)\e[39m\e[39m\r\n"
|
|
176
|
-
- delay: 40
|
|
177
|
-
content: " ▶ filters\r\n \e[32m✔ should filter tests on \"t\" \e[90m(691.810209ms)\e[39m\e[39m\r\n \e[32m✔ should filter files on \"p\" \e[90m(605.502625ms)\e[39m\e[39m\r\n"
|
|
178
|
-
- delay: 136
|
|
179
|
-
content: " \e[32m✔ should filter tests and files togetheer \e[90m(826.882875ms)\e[39m\e[39m\r\n \e[32m✔ should mention when no files found \e[90m(603.837791ms)\e[39m\e[39m\r\n"
|
|
180
|
-
- delay: 202
|
|
181
|
-
content: " \e[32m✔ should clear filters on \"c\" \e[90m(1026.169ms)\e[39m\e[39m\r\n \e[32m✔ prompt ESC should preserve previous state \e[90m(1003.537917ms)\e[39m\e[39m\r\n \e[32m✔ backspace shoud remove last character \e[90m(720.0275ms)\e[39m\e[39m\r\n \e[32m▶ \e[39mfilters \e[90m(1030.538708ms)\e[39m\r\n\r\n\e[32m▶ \e[39mtestwatch \e[90m(1035.127708ms)\e[39m\r\n\r\n\e[32m✔ j - sum \e[90m(0.452833ms)\e[39m\e[39m\r\n\e[32m✔ j - subtraction \e[90m(0.136416ms)\e[39m\e[39m\r\n\e[32m✔ index - sum \e[90m(0.457583ms)\e[39m\e[39m\r\n\e[32m✔ index - subtraction \e[90m(0.132541ms)\e[39m\e[39m\r\n\e[90m\e[39m\r\n\e[90m\e[37m\e[1mREPL Usage\e[22m\e[39m\e[90m: Press \e[37m\e[1mw\e[22m\e[39m\e[90m to show more.\e[39m"
|
|
182
|
-
- delay: 1000
|
|
183
|
-
content: "\r\n\e[1A\e[2K\e[1A\e[2K\r\n\e[1mREPL Usage\e[22m\r\n\e[90m › Press \e[37m\e[1ma\e[22m\e[39m\e[90m to run all tests.\e[39m\r\n\e[90m › Press \e[37m\e[1mp\e[22m\e[39m\e[90m to filter by a file name pattern.\e[39m\r\n\e[90m › Press \e[37m\e[1mt\e[22m\e[39m\e[90m to filter by a test name pattern.\e[39m\r\n\e[90m › Press \e[37m\e[1mq\e[22m\e[39m\e[90m to quit.\e[39m\r\n\e[90m › Press \e[37m\e[1mEnter\e[22m\e[39m\e[90m to trigger a test run.\e[39m\r\n"
|
|
184
|
-
- delay: 1000
|
|
185
|
-
content: "\r\n"
|
package/tests/fixtures/j.spec.js
DELETED
package/tests/index.test.js
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
const { describe, it } = require('node:test');
|
|
2
|
-
const { spawn } = require('node:child_process');
|
|
3
|
-
const { once } = require('node:events');
|
|
4
|
-
const { setTimeout } = require('node:timers/promises');
|
|
5
|
-
const assert = require('node:assert');
|
|
6
|
-
const path = require('node:path');
|
|
7
|
-
const { isSupported } = require('../nodeVersion');
|
|
8
|
-
|
|
9
|
-
const clear = '\x1Bc';
|
|
10
|
-
const esc = '\x1b';
|
|
11
|
-
const clearLines = '\x1B[1A\x1B[2K\x1B[1A\x1B[2K';
|
|
12
|
-
const testsRun = [
|
|
13
|
-
`✔ j - sum (*ms)
|
|
14
|
-
✔ j - subtraction (*ms)`,
|
|
15
|
-
`✔ index - sum (*ms)
|
|
16
|
-
✔ index - subtraction (*ms)`,
|
|
17
|
-
];
|
|
18
|
-
const tests = `${testsRun[0]}\n${testsRun[1]}`;
|
|
19
|
-
const mainMenu = `
|
|
20
|
-
REPL Usage
|
|
21
|
-
› Press a to run all tests.
|
|
22
|
-
› Press p to filter by a file name pattern.
|
|
23
|
-
› Press t to filter by a test name pattern.
|
|
24
|
-
› Press q to quit.
|
|
25
|
-
› Press Enter to trigger a test run.
|
|
26
|
-
`;
|
|
27
|
-
const mainMenuWithFilters = mainMenu.replace('REPL Usage', `REPL Usage
|
|
28
|
-
› Press c to clear the filters.`);
|
|
29
|
-
const compactMenu = '\nREPL Usage: Press w to show more.';
|
|
30
|
-
const filterTestsPrompt = `
|
|
31
|
-
Filter Test
|
|
32
|
-
› Press Enter to filter by a test name pattern.
|
|
33
|
-
› Press Esc to exit pattern mode.
|
|
34
|
-
|
|
35
|
-
pattern › `;
|
|
36
|
-
const filterFilesPrompt = filterTestsPrompt.replace('test', 'file').replace('Test', 'File');
|
|
37
|
-
|
|
38
|
-
async function spawnInteractive(commandSequence = 'q', args = []) {
|
|
39
|
-
let stderr = '';
|
|
40
|
-
let stdout = '';
|
|
41
|
-
const child = spawn(process.execPath, ['../../index.js', ...args], {
|
|
42
|
-
env: {}, cwd: path.resolve(__dirname, 'fixtures'),
|
|
43
|
-
});
|
|
44
|
-
child.stdin.setEncoding('utf8');
|
|
45
|
-
let writing = false;
|
|
46
|
-
async function writeInput() {
|
|
47
|
-
if (writing) return;
|
|
48
|
-
writing = true;
|
|
49
|
-
for (const char of commandSequence) {
|
|
50
|
-
child.stdin.cork();
|
|
51
|
-
child.stdin.write(`${char}`);
|
|
52
|
-
child.stdin.uncork();
|
|
53
|
-
if (char === 'a' || char === 'c' || char === '\r' || char === esc) {
|
|
54
|
-
// wait for tests to run before writing the next command
|
|
55
|
-
// eslint-disable-next-line no-await-in-loop
|
|
56
|
-
await setTimeout(1100);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
child.stderr.setEncoding('utf8');
|
|
61
|
-
child.stderr.on('data', (data) => { stderr += data; });
|
|
62
|
-
child.stdout.setEncoding('utf8');
|
|
63
|
-
child.stdout.on('data', (data) => {
|
|
64
|
-
stdout += data;
|
|
65
|
-
if (stdout.includes(mainMenu) || stdout.includes(mainMenuWithFilters)) {
|
|
66
|
-
writeInput();
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
return new Promise((resolve, reject) => {
|
|
71
|
-
child.on('close', async (code, signal) => {
|
|
72
|
-
const outputs = stdout.replace(/\(.*ms\)/g, '(*ms)').split(clear);
|
|
73
|
-
resolve({
|
|
74
|
-
code, signal, stderr, outputs,
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
child.on('error', (code, signal) => {
|
|
78
|
-
/* c8 ignore next 5 */
|
|
79
|
-
const outputs = stdout.replace(/\(.*ms\)/g, '(*ms)').split(clear);
|
|
80
|
-
// eslint-disable-next-line prefer-promise-reject-errors
|
|
81
|
-
reject({
|
|
82
|
-
code, signal, stderr, outputs,
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported node version' : false }, () => {
|
|
89
|
-
it('should run all tests on initialization', async () => {
|
|
90
|
-
const { outputs, stderr } = await spawnInteractive('q');
|
|
91
|
-
assert.strictEqual(stderr, '');
|
|
92
|
-
assert.deepStrictEqual(outputs, ['', '', `${tests}\n${mainMenu}\n`]);
|
|
93
|
-
});
|
|
94
|
-
it('should handle CTR + C', async () => {
|
|
95
|
-
const { outputs, stderr } = await spawnInteractive('\x03');
|
|
96
|
-
assert.strictEqual(stderr, '');
|
|
97
|
-
assert.deepStrictEqual(outputs, ['', '', `${tests}\n${mainMenu}\n`]);
|
|
98
|
-
});
|
|
99
|
-
it('should handle CTR + D', async () => {
|
|
100
|
-
const { outputs, stderr } = await spawnInteractive('\x04');
|
|
101
|
-
assert.strictEqual(stderr, '');
|
|
102
|
-
assert.deepStrictEqual(outputs, ['', '', `${tests}\n${mainMenu}\n`]);
|
|
103
|
-
});
|
|
104
|
-
it('should exit on sigkill', async () => {
|
|
105
|
-
const child = spawn(process.execPath, ['../../index.js'], {
|
|
106
|
-
env: {}, cwd: path.resolve(__dirname, 'fixtures'),
|
|
107
|
-
});
|
|
108
|
-
let stderr = '';
|
|
109
|
-
let stdout = '';
|
|
110
|
-
child.stderr.setEncoding('utf8');
|
|
111
|
-
child.stderr.on('data', (data) => { stderr += data; });
|
|
112
|
-
child.stdout.setEncoding('utf8');
|
|
113
|
-
child.stdout.on('data', (data) => { stdout += data; });
|
|
114
|
-
child.kill('SIGKILL');
|
|
115
|
-
const [code, signal] = await once(child, 'close');
|
|
116
|
-
assert.strictEqual(stderr, '');
|
|
117
|
-
assert.strictEqual(stdout, '');
|
|
118
|
-
assert.strictEqual(signal, 'SIGKILL');
|
|
119
|
-
assert.strictEqual(code, null);
|
|
120
|
-
});
|
|
121
|
-
it('should run all tests on "a"', async () => {
|
|
122
|
-
const { outputs, stderr } = await spawnInteractive('aq');
|
|
123
|
-
assert.strictEqual(stderr, '');
|
|
124
|
-
assert.deepStrictEqual(outputs, ['', '', `${tests}\n${mainMenu}`, '', `${tests}\n${compactMenu}\n`]);
|
|
125
|
-
});
|
|
126
|
-
it('should run all tests on Enter', async () => {
|
|
127
|
-
const { outputs, stderr } = await spawnInteractive('\rq');
|
|
128
|
-
assert.strictEqual(stderr, '');
|
|
129
|
-
assert.deepStrictEqual(outputs, ['', '', `${tests}\n${mainMenu}`, '', `${tests}\n${compactMenu}\n`]);
|
|
130
|
-
});
|
|
131
|
-
it('should show full menu on "w" after running tests', async () => {
|
|
132
|
-
const { outputs, stderr } = await spawnInteractive('awq');
|
|
133
|
-
assert.strictEqual(stderr, '');
|
|
134
|
-
assert.deepStrictEqual(outputs, [
|
|
135
|
-
'',
|
|
136
|
-
'',
|
|
137
|
-
`${tests}\n${mainMenu}`,
|
|
138
|
-
'',
|
|
139
|
-
`${tests}\n${compactMenu}\n${clearLines}${mainMenu}\n`,
|
|
140
|
-
]);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
describe('filters', () => {
|
|
144
|
-
it('should filter tests on "t"', async () => {
|
|
145
|
-
const { outputs, stderr } = await spawnInteractive(['t', 'sub', '\r', 'w', 'q'].join(''));
|
|
146
|
-
const activeFilters = '\nActive Filters: test name /sub/\n';
|
|
147
|
-
assert.strictEqual(stderr, '');
|
|
148
|
-
assert.deepStrictEqual(outputs, [
|
|
149
|
-
'',
|
|
150
|
-
'',
|
|
151
|
-
`${tests}\n${mainMenu}`,
|
|
152
|
-
`${filterTestsPrompt}sub`,
|
|
153
|
-
'',
|
|
154
|
-
'',
|
|
155
|
-
`${tests
|
|
156
|
-
.replace('✔ j - sum (*ms)', '﹣ j - sum (*ms) # SKIP')
|
|
157
|
-
.replace('✔ index - sum (*ms)', '﹣ index - sum (*ms) # SKIP')
|
|
158
|
-
}\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`,
|
|
159
|
-
]);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
describe('files filter', () => {
|
|
163
|
-
it('should not exit if no test found on first run', async () => {
|
|
164
|
-
const { outputs, stderr } = await spawnInteractive('q', ['notexist']);
|
|
165
|
-
const activeFilters = '\nActive Filters: file name **/notexist*.*\n';
|
|
166
|
-
const notFound = '\nNo files found for pattern **/notexist*.*';
|
|
167
|
-
assert.strictEqual(stderr, '');
|
|
168
|
-
assert.deepStrictEqual(outputs, [
|
|
169
|
-
'',
|
|
170
|
-
`${notFound}\n${activeFilters}${mainMenuWithFilters}\n`,
|
|
171
|
-
]);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it('should set first argument as file filter', async () => {
|
|
175
|
-
const { outputs, stderr } = await spawnInteractive('q', ['ind']);
|
|
176
|
-
const activeFilters = '\nActive Filters: file name **/ind*.*\n';
|
|
177
|
-
assert.strictEqual(stderr, '');
|
|
178
|
-
assert.deepStrictEqual(outputs, [
|
|
179
|
-
'',
|
|
180
|
-
'',
|
|
181
|
-
`${testsRun[1]}\n${activeFilters}${mainMenuWithFilters}\n`,
|
|
182
|
-
]);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it('should filter files on "p"', async () => {
|
|
186
|
-
const { outputs, stderr } = await spawnInteractive(['p', 'index', '\r', 'w', 'q'].join(''));
|
|
187
|
-
const activeFilters = '\nActive Filters: file name **/index*.*\n';
|
|
188
|
-
assert.strictEqual(stderr, '');
|
|
189
|
-
assert.deepStrictEqual(outputs, [
|
|
190
|
-
'',
|
|
191
|
-
'',
|
|
192
|
-
`${tests}\n${mainMenu}`,
|
|
193
|
-
`${filterFilesPrompt}index`,
|
|
194
|
-
'',
|
|
195
|
-
'',
|
|
196
|
-
`${testsRun[1]}\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`,
|
|
197
|
-
]);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it('should filter partial file names on "p"', async () => {
|
|
201
|
-
const { outputs, stderr } = await spawnInteractive(['p', 'ind', '\r', 'w', 'q'].join(''));
|
|
202
|
-
const activeFilters = '\nActive Filters: file name **/ind*.*\n';
|
|
203
|
-
assert.strictEqual(stderr, '');
|
|
204
|
-
assert.deepStrictEqual(outputs, [
|
|
205
|
-
'',
|
|
206
|
-
'',
|
|
207
|
-
`${tests}\n${mainMenu}`,
|
|
208
|
-
`${filterFilesPrompt}ind`,
|
|
209
|
-
'',
|
|
210
|
-
'',
|
|
211
|
-
`${testsRun[1]}\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`,
|
|
212
|
-
]);
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
it('should filter tests and files togetheer', async () => {
|
|
216
|
-
const { outputs, stderr } = await spawnInteractive(['p', 'index', '\r', 't', 'sum', '\r', 'w', 'q'].join(''));
|
|
217
|
-
const activeFilters = '\nActive Filters: file name **/index*.*, test name /sum/\n';
|
|
218
|
-
assert.strictEqual(stderr, '');
|
|
219
|
-
assert.strictEqual(outputs.length, 11);
|
|
220
|
-
assert.strictEqual(outputs[10], `${testsRun[1].replace('✔ index - subtraction (*ms)', '﹣ index - subtraction (*ms) # SKIP')}\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it('should mention when no files found', async () => {
|
|
224
|
-
const { outputs, stderr } = await spawnInteractive(['p', 'nothing', '\r', 'w', 'q'].join(''));
|
|
225
|
-
const activeFilters = '\nActive Filters: file name **/nothing*.*\n';
|
|
226
|
-
const notFound = '\nNo files found for pattern **/nothing*.*';
|
|
227
|
-
assert.strictEqual(stderr, '');
|
|
228
|
-
assert.deepStrictEqual(outputs, [
|
|
229
|
-
'',
|
|
230
|
-
'',
|
|
231
|
-
`${tests}\n${mainMenu}`,
|
|
232
|
-
`${filterFilesPrompt}nothing`,
|
|
233
|
-
'',
|
|
234
|
-
`${notFound}\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`,
|
|
235
|
-
]);
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it('should clear filters on "c"', async () => {
|
|
239
|
-
const { outputs, stderr } = await spawnInteractive(['p', 'index', '\r', 'w', 't', 'sum', '\r', 'w', 'c', 'w', 'q'].join(''));
|
|
240
|
-
assert.strictEqual(stderr, '');
|
|
241
|
-
assert.strictEqual(outputs.length, 13);
|
|
242
|
-
|
|
243
|
-
assert.match(outputs[6], /Active Filters: file name \*\*\/index\*\.\*/);
|
|
244
|
-
assert.match(outputs[7], /Active Filters: file name \*\*\/index\*\.\*/);
|
|
245
|
-
assert.match(outputs[10], /Active Filters: file name \*\*\/index\*\.\*, test name \/sum\//);
|
|
246
|
-
assert.strictEqual(outputs[12], `${tests}\n${compactMenu}\n${clearLines}${mainMenu}\n`);
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it('prompt ESC should preserve previous state', async () => {
|
|
250
|
-
const { outputs } = await spawnInteractive(['p', esc, 'p', 'filter', '\r', 'p', esc, 'q'].join(''));
|
|
251
|
-
const notFound = '\nNo files found for pattern **/filter*.*';
|
|
252
|
-
const activeFilters = '\nActive Filters: file name **/filter*.*\n';
|
|
253
|
-
assert.deepStrictEqual(outputs, [
|
|
254
|
-
'',
|
|
255
|
-
'',
|
|
256
|
-
`${tests}\n${mainMenu}`,
|
|
257
|
-
`${filterFilesPrompt}`,
|
|
258
|
-
'',
|
|
259
|
-
'',
|
|
260
|
-
`${tests}\n${compactMenu}`,
|
|
261
|
-
`${filterFilesPrompt}filter`,
|
|
262
|
-
'',
|
|
263
|
-
`${notFound}\n${compactMenu}`,
|
|
264
|
-
`${activeFilters}${filterFilesPrompt}`,
|
|
265
|
-
'',
|
|
266
|
-
`${notFound}\n${compactMenu}\n`,
|
|
267
|
-
]);
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it('backspace should remove last character', async () => {
|
|
271
|
-
const backspace = '\x7f';
|
|
272
|
-
const { outputs, stderr } = await spawnInteractive(['p', `noth123${backspace}${backspace}ing`, '\r', 'w', 'q'].join(''));
|
|
273
|
-
assert.strictEqual(stderr, '');
|
|
274
|
-
assert.strictEqual(outputs.length, 6);
|
|
275
|
-
assert.match(outputs[5], /No files found for pattern \*\*\/noth1ing\*\.\*/);
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
});
|