@reporters/testwatch 1.2.0 → 1.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.1](https://github.com/MoLow/reporters/compare/testwatch-v1.2.0...testwatch-v1.2.1) (2023-07-02)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * clear screen before tests ([3d3f67c](https://github.com/MoLow/reporters/commit/3d3f67cddd7047c857e001066021933eb1381ec3))
9
+
3
10
  ## [1.2.0](https://github.com/MoLow/reporters/compare/testwatch-v1.1.1...testwatch-v1.2.0) (2023-06-19)
4
11
 
5
12
 
package/index.js CHANGED
@@ -57,13 +57,13 @@ class REPL {
57
57
  #emitter = new EventEmitter();
58
58
 
59
59
  async #runTests() {
60
+ this.#clear();
60
61
  this.#controller.abort();
61
62
  this.#controller = new AbortController();
62
63
  const filter = this.#filesFilter ? `**/${this.#filesFilter}*.*` : '**/?(*.)+(spec|test).[jt]s';
63
64
  const files = await glob(filter, { ignore: 'node_modules/**' });
64
65
 
65
66
  if (!files.length) {
66
- this.#clear();
67
67
  process.stdout.write(chalk.red(`\nNo files found for pattern ${filter}\n`));
68
68
  this.#emitter.emit('drained');
69
69
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reporters/testwatch",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "An interactive repl for `node:test`",
5
5
  "keywords": [
6
6
  "node:test",
@@ -89,17 +89,17 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
89
89
  it('should run all tests on initialization', async () => {
90
90
  const { outputs, stderr } = await spawnInteractive('q');
91
91
  assert.strictEqual(stderr, '');
92
- assert.deepStrictEqual(outputs, ['', `${tests}\n${mainMenu}\n`]);
92
+ assert.deepStrictEqual(outputs, ['', '', `${tests}\n${mainMenu}\n`]);
93
93
  });
94
94
  it('should handle CTR + C', async () => {
95
95
  const { outputs, stderr } = await spawnInteractive('\x03');
96
96
  assert.strictEqual(stderr, '');
97
- assert.deepStrictEqual(outputs, ['', `${tests}\n${mainMenu}\n`]);
97
+ assert.deepStrictEqual(outputs, ['', '', `${tests}\n${mainMenu}\n`]);
98
98
  });
99
99
  it('should handle CTR + D', async () => {
100
100
  const { outputs, stderr } = await spawnInteractive('\x04');
101
101
  assert.strictEqual(stderr, '');
102
- assert.deepStrictEqual(outputs, ['', `${tests}\n${mainMenu}\n`]);
102
+ assert.deepStrictEqual(outputs, ['', '', `${tests}\n${mainMenu}\n`]);
103
103
  });
104
104
  it('should exit on sigkill', async () => {
105
105
  const child = spawn(process.execPath, ['../../index.js'], {
@@ -121,19 +121,21 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
121
121
  it('should run all tests on "a"', async () => {
122
122
  const { outputs, stderr } = await spawnInteractive('aq');
123
123
  assert.strictEqual(stderr, '');
124
- assert.deepStrictEqual(outputs, ['', `${tests}\n${mainMenu}`, `${tests}\n${compactMenu}\n`]);
124
+ assert.deepStrictEqual(outputs, ['', '', `${tests}\n${mainMenu}`, '', `${tests}\n${compactMenu}\n`]);
125
125
  });
126
126
  it('should run all tests on Enter', async () => {
127
127
  const { outputs, stderr } = await spawnInteractive('\rq');
128
128
  assert.strictEqual(stderr, '');
129
- assert.deepStrictEqual(outputs, ['', `${tests}\n${mainMenu}`, `${tests}\n${compactMenu}\n`]);
129
+ assert.deepStrictEqual(outputs, ['', '', `${tests}\n${mainMenu}`, '', `${tests}\n${compactMenu}\n`]);
130
130
  });
131
131
  it('should show full menu on "w" after running tests', async () => {
132
132
  const { outputs, stderr } = await spawnInteractive('awq');
133
133
  assert.strictEqual(stderr, '');
134
134
  assert.deepStrictEqual(outputs, [
135
+ '',
135
136
  '',
136
137
  `${tests}\n${mainMenu}`,
138
+ '',
137
139
  `${tests}\n${compactMenu}\n${clearLines}${mainMenu}\n`,
138
140
  ]);
139
141
  });
@@ -144,10 +146,12 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
144
146
  const activeFilters = '\nActive Filters: test name /sub/\n';
145
147
  assert.strictEqual(stderr, '');
146
148
  assert.deepStrictEqual(outputs, [
149
+ '',
147
150
  '',
148
151
  `${tests}\n${mainMenu}`,
149
152
  `${filterTestsPrompt}sub`,
150
153
  '',
154
+ '',
151
155
  `${tests
152
156
  .replace('✔ j - sum (*ms)', '﹣ j - sum (*ms) # SKIP')
153
157
  .replace('✔ index - sum (*ms)', '﹣ index - sum (*ms) # SKIP')
@@ -172,6 +176,7 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
172
176
  const activeFilters = '\nActive Filters: file name **/ind*.*\n';
173
177
  assert.strictEqual(stderr, '');
174
178
  assert.deepStrictEqual(outputs, [
179
+ '',
175
180
  '',
176
181
  `${testsRun[1]}\n${activeFilters}${mainMenuWithFilters}\n`,
177
182
  ]);
@@ -182,10 +187,12 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
182
187
  const activeFilters = '\nActive Filters: file name **/index*.*\n';
183
188
  assert.strictEqual(stderr, '');
184
189
  assert.deepStrictEqual(outputs, [
190
+ '',
185
191
  '',
186
192
  `${tests}\n${mainMenu}`,
187
193
  `${filterFilesPrompt}index`,
188
194
  '',
195
+ '',
189
196
  `${testsRun[1]}\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`,
190
197
  ]);
191
198
  });
@@ -195,10 +202,12 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
195
202
  const activeFilters = '\nActive Filters: file name **/ind*.*\n';
196
203
  assert.strictEqual(stderr, '');
197
204
  assert.deepStrictEqual(outputs, [
205
+ '',
198
206
  '',
199
207
  `${tests}\n${mainMenu}`,
200
208
  `${filterFilesPrompt}ind`,
201
209
  '',
210
+ '',
202
211
  `${testsRun[1]}\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`,
203
212
  ]);
204
213
  });
@@ -207,8 +216,8 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
207
216
  const { outputs, stderr } = await spawnInteractive(['p', 'index', '\r', 't', 'sum', '\r', 'w', 'q'].join(''));
208
217
  const activeFilters = '\nActive Filters: file name **/index*.*, test name /sum/\n';
209
218
  assert.strictEqual(stderr, '');
210
- assert.strictEqual(outputs.length, 8);
211
- assert.strictEqual(outputs[7], `${testsRun[1].replace('✔ index - subtraction (*ms)', '﹣ index - subtraction (*ms) # SKIP')}\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`);
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`);
212
221
  });
213
222
 
214
223
  it('should mention when no files found', async () => {
@@ -217,6 +226,7 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
217
226
  const notFound = '\nNo files found for pattern **/nothing*.*';
218
227
  assert.strictEqual(stderr, '');
219
228
  assert.deepStrictEqual(outputs, [
229
+ '',
220
230
  '',
221
231
  `${tests}\n${mainMenu}`,
222
232
  `${filterFilesPrompt}nothing`,
@@ -228,12 +238,12 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
228
238
  it('should clear filters on "c"', async () => {
229
239
  const { outputs, stderr } = await spawnInteractive(['p', 'index', '\r', 'w', 't', 'sum', '\r', 'w', 'c', 'w', 'q'].join(''));
230
240
  assert.strictEqual(stderr, '');
231
- assert.strictEqual(outputs.length, 9);
241
+ assert.strictEqual(outputs.length, 13);
232
242
 
233
- assert.match(outputs[4], /Active Filters: file name \*\*\/index\*\.\*/);
234
- assert.match(outputs[5], /Active Filters: file name \*\*\/index\*\.\*/);
235
- assert.match(outputs[7], /Active Filters: file name \*\*\/index\*\.\*, test name \/sum\//);
236
- assert.strictEqual(outputs[8], `${tests}\n${compactMenu}\n${clearLines}${mainMenu}\n`);
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`);
237
247
  });
238
248
 
239
249
  it('prompt ESC should preserve previous state', async () => {
@@ -241,10 +251,12 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
241
251
  const notFound = '\nNo files found for pattern **/filter*.*';
242
252
  const activeFilters = '\nActive Filters: file name **/filter*.*\n';
243
253
  assert.deepStrictEqual(outputs, [
254
+ '',
244
255
  '',
245
256
  `${tests}\n${mainMenu}`,
246
257
  `${filterFilesPrompt}`,
247
258
  '',
259
+ '',
248
260
  `${tests}\n${compactMenu}`,
249
261
  `${filterFilesPrompt}filter`,
250
262
  '',
@@ -255,12 +267,12 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
255
267
  ]);
256
268
  });
257
269
 
258
- it('backspace shoud remove last character', async () => {
270
+ it('backspace should remove last character', async () => {
259
271
  const backspace = '\x7f';
260
272
  const { outputs, stderr } = await spawnInteractive(['p', `noth123${backspace}${backspace}ing`, '\r', 'w', 'q'].join(''));
261
273
  assert.strictEqual(stderr, '');
262
- assert.strictEqual(outputs.length, 5);
263
- assert.match(outputs[4], /No files found for pattern \*\*\/noth1ing\*\.\*/);
274
+ assert.strictEqual(outputs.length, 6);
275
+ assert.match(outputs[5], /No files found for pattern \*\*\/noth1ing\*\.\*/);
264
276
  });
265
277
  });
266
278
  });