@reporters/testwatch 1.0.0 → 1.1.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,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.1.1](https://github.com/MoLow/reporters/compare/testwatch-v1.1.0...testwatch-v1.1.1) (2023-06-12)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * increas maximum listeners of event emitters ([b16d2ab](https://github.com/MoLow/reporters/commit/b16d2ab3b55554e1aaa9b9ca2222254bac364803))
9
+ * support partial file name filter ([2b3f0ab](https://github.com/MoLow/reporters/commit/2b3f0abe0be37450c7b9189667ad47d4d39a4252))
10
+
11
+ ## [1.1.0](https://github.com/MoLow/reporters/compare/testwatch-v1.0.0...testwatch-v1.1.0) (2023-06-08)
12
+
13
+
14
+ ### Features
15
+
16
+ * fix @reporters/bail docs ([32fd66b](https://github.com/MoLow/reporters/commit/32fd66bdf788a2d6067bac72cee9fbc50b2d76e3))
17
+
3
18
  ## 1.0.0 (2023-06-08)
4
19
 
5
20
 
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  # Interactive Test Runner
4
4
  An interactive REPL for `node:test` watch mode.
5
5
 
6
- ![cli](assets/cli.gif)
6
+ ![cli](https://raw.githubusercontent.com/MoLow/reporters/77f69c450ab0cb204fa8b81caf12516df03cdc13/packages/testwatch/assets/cli.gif)
7
7
 
8
8
  ## Installation
9
9
 
package/index.js CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  const { run } = require('node:test');
4
4
  const { pipeline } = require('node:stream/promises');
5
- const { on, once, EventEmitter } = require('node:events');
5
+ const {
6
+ on, once, EventEmitter, setMaxListeners,
7
+ } = require('node:events');
6
8
  const { glob } = require('glob');
7
9
  const chalk = require('chalk');
8
10
  const { isSupported } = require('./nodeVersion');
@@ -28,6 +30,7 @@ const KEY_NAMES = {
28
30
  };
29
31
  const UnknownCommand = Symbol('UnknownKey');
30
32
 
33
+ setMaxListeners(Infinity);
31
34
  process.stdout.setMaxListeners(Infinity);
32
35
  process.setMaxListeners(Infinity);
33
36
  process.stdin.setEncoding('utf8');
@@ -56,7 +59,7 @@ class REPL {
56
59
  async #runTests() {
57
60
  this.#controller.abort();
58
61
  this.#controller = new AbortController();
59
- const filter = this.#filesFilter ? `**/${this.#filesFilter}.*` : '**/*.test.js';
62
+ const filter = this.#filesFilter ? `**/${this.#filesFilter}*.*` : '**/*.test.js';
60
63
  const files = await glob(filter, { ignore: 'node_modules/**' });
61
64
 
62
65
  if (!files.length) {
@@ -200,7 +203,7 @@ class REPL {
200
203
  if (this.#filesFilter || this.#testsFilter) {
201
204
  const message = `
202
205
  ${chalk.white.bold('Active Filters:')} \
203
- ${this.#filesFilter ? `file name ${chalk.gray('**/')}${chalk.yellow(this.#filesFilter)}${chalk.gray('.*')}` : ''}\
206
+ ${this.#filesFilter ? `file name ${chalk.gray('**/')}${chalk.yellow(this.#filesFilter)}${chalk.gray('*.*')}` : ''}\
204
207
  ${(this.#testsFilter && this.#filesFilter) ? ', ' : ''}\
205
208
  ${this.#testsFilter ? `test name ${chalk.yellow(`/${this.#testsFilter}/`)}` : ''}
206
209
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reporters/testwatch",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "An interactive repl for `node:test`",
5
5
  "keywords": [
6
6
  "node:test",
@@ -53,7 +53,7 @@ async function spawnInteractive(commandSequence = 'q') {
53
53
  if (char === 'a' || char === 'c' || char === '\r' || char === esc) {
54
54
  // wait for tests to run before writing the next command
55
55
  // eslint-disable-next-line no-await-in-loop
56
- await setTimeout(1200);
56
+ await setTimeout(1100);
57
57
  }
58
58
  }
59
59
  }
@@ -155,21 +155,36 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
155
155
  ]);
156
156
  });
157
157
 
158
- it('should filter files on "p"', async () => {
159
- const { outputs, stderr } = await spawnInteractive(['p', 'index', '\r', 'w', 'q'].join(''));
160
- const activeFilters = '\nActive Filters: file name **/index.*\n';
161
- assert.strictEqual(stderr, '');
162
- assert.deepStrictEqual(outputs, [
163
- '',
164
- `${tests}\n${mainMenu}`,
165
- `${filterFilesPrompt}index`,
166
- '',
167
- `${testsRun[1]}\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`,
168
- ]);
158
+ describe('files filter', () => {
159
+ it('should filter files on "p"', async () => {
160
+ const { outputs, stderr } = await spawnInteractive(['p', 'index', '\r', 'w', 'q'].join(''));
161
+ const activeFilters = '\nActive Filters: file name **/index*.*\n';
162
+ assert.strictEqual(stderr, '');
163
+ assert.deepStrictEqual(outputs, [
164
+ '',
165
+ `${tests}\n${mainMenu}`,
166
+ `${filterFilesPrompt}index`,
167
+ '',
168
+ `${testsRun[1]}\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`,
169
+ ]);
170
+ });
171
+
172
+ it('should filter partial file names on "p"', async () => {
173
+ const { outputs, stderr } = await spawnInteractive(['p', 'ind', '\r', 'w', 'q'].join(''));
174
+ const activeFilters = '\nActive Filters: file name **/ind*.*\n';
175
+ assert.strictEqual(stderr, '');
176
+ assert.deepStrictEqual(outputs, [
177
+ '',
178
+ `${tests}\n${mainMenu}`,
179
+ `${filterFilesPrompt}ind`,
180
+ '',
181
+ `${testsRun[1]}\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`,
182
+ ]);
183
+ });
169
184
  });
170
185
  it('should filter tests and files togetheer', async () => {
171
186
  const { outputs, stderr } = await spawnInteractive(['p', 'index', '\r', 't', 'sum', '\r', 'w', 'q'].join(''));
172
- const activeFilters = '\nActive Filters: file name **/index.*, test name /sum/\n';
187
+ const activeFilters = '\nActive Filters: file name **/index*.*, test name /sum/\n';
173
188
  assert.strictEqual(stderr, '');
174
189
  assert.strictEqual(outputs.length, 8);
175
190
  assert.strictEqual(outputs[7], `${testsRun[1].replace('✔ index - subtraction (*ms)', '﹣ index - subtraction (*ms) # SKIP')}\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`);
@@ -177,8 +192,8 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
177
192
 
178
193
  it('should mention when no files found', async () => {
179
194
  const { outputs, stderr } = await spawnInteractive(['p', 'nothing', '\r', 'w', 'q'].join(''));
180
- const activeFilters = '\nActive Filters: file name **/nothing.*\n';
181
- const notFound = '\nNo files found for pattern **/nothing.*';
195
+ const activeFilters = '\nActive Filters: file name **/nothing*.*\n';
196
+ const notFound = '\nNo files found for pattern **/nothing*.*';
182
197
  assert.strictEqual(stderr, '');
183
198
  assert.deepStrictEqual(outputs, [
184
199
  '',
@@ -194,16 +209,16 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
194
209
  assert.strictEqual(stderr, '');
195
210
  assert.strictEqual(outputs.length, 9);
196
211
 
197
- assert.match(outputs[4], /Active Filters: file name \*\*\/index\.\*/);
198
- assert.match(outputs[5], /Active Filters: file name \*\*\/index\.\*/);
199
- assert.match(outputs[7], /Active Filters: file name \*\*\/index\.\*, test name \/sum\//);
212
+ assert.match(outputs[4], /Active Filters: file name \*\*\/index\*\.\*/);
213
+ assert.match(outputs[5], /Active Filters: file name \*\*\/index\*\.\*/);
214
+ assert.match(outputs[7], /Active Filters: file name \*\*\/index\*\.\*, test name \/sum\//);
200
215
  assert.strictEqual(outputs[8], `${tests}\n${compactMenu}\n${clearLines}${mainMenu}\n`);
201
216
  });
202
217
 
203
218
  it('prompt ESC should preserve previous state', async () => {
204
219
  const { outputs } = await spawnInteractive(['p', esc, 'p', 'filter', '\r', 'p', esc, 'q'].join(''));
205
- const notFound = '\nNo files found for pattern **/filter.*';
206
- const activeFilters = '\nActive Filters: file name **/filter.*\n';
220
+ const notFound = '\nNo files found for pattern **/filter*.*';
221
+ const activeFilters = '\nActive Filters: file name **/filter*.*\n';
207
222
  assert.deepStrictEqual(outputs, [
208
223
  '',
209
224
  `${tests}\n${mainMenu}`,
@@ -224,7 +239,7 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod
224
239
  const { outputs, stderr } = await spawnInteractive(['p', `noth123${backspace}${backspace}ing`, '\r', 'w', 'q'].join(''));
225
240
  assert.strictEqual(stderr, '');
226
241
  assert.strictEqual(outputs.length, 5);
227
- assert.match(outputs[4], /No files found for pattern \*\*\/noth1ing\.\*/);
242
+ assert.match(outputs[4], /No files found for pattern \*\*\/noth1ing\*\.\*/);
228
243
  });
229
244
  });
230
245
  });