ava 3.15.0 → 4.0.0

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.
Files changed (72) hide show
  1. package/entrypoints/cli.mjs +4 -0
  2. package/entrypoints/eslint-plugin-helper.cjs +109 -0
  3. package/entrypoints/main.cjs +2 -0
  4. package/entrypoints/main.mjs +1 -0
  5. package/entrypoints/plugin.cjs +2 -0
  6. package/entrypoints/plugin.mjs +4 -0
  7. package/index.d.ts +6 -816
  8. package/lib/api.js +108 -49
  9. package/lib/assert.js +255 -270
  10. package/lib/chalk.js +9 -14
  11. package/lib/cli.js +118 -112
  12. package/lib/code-excerpt.js +12 -17
  13. package/lib/concordance-options.js +29 -65
  14. package/lib/context-ref.js +3 -6
  15. package/lib/create-chain.js +32 -20
  16. package/lib/environment-variables.js +1 -4
  17. package/lib/eslint-plugin-helper-worker.js +73 -0
  18. package/lib/extensions.js +2 -2
  19. package/lib/fork.js +81 -84
  20. package/lib/glob-helpers.cjs +140 -0
  21. package/lib/globs.js +136 -163
  22. package/lib/{ipc-flow-control.js → ipc-flow-control.cjs} +1 -0
  23. package/lib/is-ci.js +4 -2
  24. package/lib/like-selector.js +7 -13
  25. package/lib/line-numbers.js +11 -18
  26. package/lib/load-config.js +56 -180
  27. package/lib/module-types.js +3 -7
  28. package/lib/node-arguments.js +4 -5
  29. package/lib/{now-and-timers.js → now-and-timers.cjs} +0 -0
  30. package/lib/parse-test-args.js +22 -11
  31. package/lib/pkg.cjs +2 -0
  32. package/lib/plugin-support/shared-worker-loader.js +45 -48
  33. package/lib/plugin-support/shared-workers.js +24 -46
  34. package/lib/provider-manager.js +20 -14
  35. package/lib/reporters/beautify-stack.js +6 -12
  36. package/lib/reporters/colors.js +40 -15
  37. package/lib/reporters/default.js +114 -364
  38. package/lib/reporters/format-serialized-error.js +7 -18
  39. package/lib/reporters/improper-usage-messages.js +8 -9
  40. package/lib/reporters/prefix-title.js +17 -15
  41. package/lib/reporters/tap.js +18 -25
  42. package/lib/run-status.js +29 -23
  43. package/lib/runner.js +157 -172
  44. package/lib/scheduler.js +53 -0
  45. package/lib/serialize-error.js +61 -64
  46. package/lib/snapshot-manager.js +271 -289
  47. package/lib/test.js +135 -291
  48. package/lib/watcher.js +69 -44
  49. package/lib/worker/base.js +208 -0
  50. package/lib/worker/channel.cjs +290 -0
  51. package/lib/worker/dependency-tracker.js +24 -23
  52. package/lib/worker/{ensure-forked.js → guard-environment.cjs} +5 -4
  53. package/lib/worker/line-numbers.js +58 -20
  54. package/lib/worker/main.cjs +12 -0
  55. package/lib/worker/{options.js → options.cjs} +0 -0
  56. package/lib/worker/{plugin.js → plugin.cjs} +30 -21
  57. package/lib/worker/state.cjs +5 -0
  58. package/lib/worker/utils.cjs +6 -0
  59. package/package.json +71 -68
  60. package/plugin.d.ts +51 -53
  61. package/readme.md +5 -13
  62. package/types/assertions.d.ts +327 -0
  63. package/types/subscribable.ts +6 -0
  64. package/types/test-fn.d.ts +231 -0
  65. package/types/try-fn.d.ts +58 -0
  66. package/cli.js +0 -11
  67. package/eslint-plugin-helper.js +0 -201
  68. package/index.js +0 -8
  69. package/lib/worker/ipc.js +0 -201
  70. package/lib/worker/main.js +0 -21
  71. package/lib/worker/subprocess.js +0 -266
  72. package/plugin.js +0 -9
@@ -1,25 +1,24 @@
1
- 'use strict';
2
- const os = require('os');
3
- const path = require('path');
4
- const stream = require('stream');
5
-
6
- const cliCursor = require('cli-cursor');
7
- const figures = require('figures');
8
- const indentString = require('indent-string');
9
- const ora = require('ora');
10
- const plur = require('plur');
11
- const prettyMs = require('pretty-ms');
12
- const trimOffNewlines = require('trim-off-newlines');
13
-
14
- const chalk = require('../chalk').get();
15
- const codeExcerpt = require('../code-excerpt');
16
- const beautifyStack = require('./beautify-stack');
17
- const colors = require('./colors');
18
- const formatSerializedError = require('./format-serialized-error');
19
- const improperUsageMessages = require('./improper-usage-messages');
20
- const prefixTitle = require('./prefix-title');
21
-
22
- const nodeInternals = require('stack-utils').nodeInternals();
1
+ import os from 'node:os';
2
+ import path from 'node:path';
3
+ import stream from 'node:stream';
4
+ import {fileURLToPath} from 'node:url';
5
+
6
+ import figures from 'figures';
7
+ import indentString from 'indent-string';
8
+ import plur from 'plur';
9
+ import prettyMs from 'pretty-ms';
10
+ import StackUtils from 'stack-utils';
11
+
12
+ import {chalk} from '../chalk.js';
13
+ import codeExcerpt from '../code-excerpt.js';
14
+
15
+ import beautifyStack from './beautify-stack.js';
16
+ import colors from './colors.js';
17
+ import formatSerializedError from './format-serialized-error.js';
18
+ import improperUsageMessage from './improper-usage-messages.js';
19
+ import prefixTitle from './prefix-title.js';
20
+
21
+ const nodeInternals = StackUtils.nodeInternals();
23
22
 
24
23
  class LineWriter extends stream.Writable {
25
24
  constructor(dest) {
@@ -52,129 +51,48 @@ class LineWriter extends stream.Writable {
52
51
  }
53
52
  }
54
53
 
55
- class LineWriterWithSpinner extends LineWriter {
56
- constructor(dest, spinner) {
57
- super(dest);
58
-
59
- this.lastSpinnerText = '';
60
- this.spinner = spinner;
61
- }
62
-
63
- _write(chunk, _, callback) {
64
- this.spinner.clear();
65
- this._writeWithSpinner(chunk.toString('utf8'));
66
-
67
- callback();
68
- }
69
-
70
- _writev(pieces, callback) {
71
- // Discard the current spinner output. Any lines that were meant to be
72
- // preserved should be rewritten.
73
- this.spinner.clear();
74
-
75
- const last = pieces.pop();
76
- for (const piece of pieces) {
77
- this.dest.write(piece.chunk);
78
- }
79
-
80
- this._writeWithSpinner(last.chunk.toString('utf8'));
81
- callback();
82
- }
83
-
84
- _writeWithSpinner(string) {
85
- if (!this.spinner.isSpinning) {
86
- this.dest.write(string);
87
- return;
88
- }
89
-
90
- this.lastSpinnerText = string;
91
- // Ignore whitespace at the end of the chunk. We're continiously rewriting
92
- // the last line through the spinner. Also be careful to remove the indent
93
- // as the spinner adds its own.
94
- this.spinner.text = string.trimEnd().slice(2);
95
- this.spinner.render();
96
- }
97
- }
98
-
99
54
  function manageCorking(stream) {
100
- let corked = false;
101
- const cork = () => {
102
- corked = true;
103
- stream.cork();
104
- };
105
-
106
- const uncork = () => {
107
- corked = false;
108
- stream.uncork();
109
- };
110
-
111
55
  return {
112
- decorateFlushingWriter(fn) {
113
- return function (...args) {
114
- if (corked) {
115
- stream.uncork();
116
- }
117
-
118
- try {
119
- return fn.apply(this, args);
120
- } finally {
121
- if (corked) {
122
- stream.cork();
123
- }
124
- }
125
- };
126
- },
127
-
128
56
  decorateWriter(fn) {
129
57
  return function (...args) {
130
- cork();
58
+ stream.cork();
131
59
  try {
132
60
  return fn.apply(this, args);
133
61
  } finally {
134
- uncork();
62
+ stream.uncork();
135
63
  }
136
64
  };
137
- }
65
+ },
138
66
  };
139
67
  }
140
68
 
141
- class Reporter {
69
+ export default class Reporter {
142
70
  constructor({
143
- verbose,
71
+ extensions,
144
72
  reportStream,
145
73
  stdStream,
146
74
  projectDir,
147
75
  watching,
148
- spinner,
149
- durationThreshold
76
+ durationThreshold,
150
77
  }) {
151
- this.verbose = verbose;
78
+ this.extensions = extensions;
152
79
  this.reportStream = reportStream;
153
80
  this.stdStream = stdStream;
154
81
  this.watching = watching;
155
- this.relativeFile = file => path.relative(projectDir, file);
82
+ this.relativeFile = file => {
83
+ if (file.startsWith('file://')) {
84
+ file = fileURLToPath(file);
85
+ }
156
86
 
157
- const {decorateWriter, decorateFlushingWriter} = manageCorking(this.reportStream);
87
+ return path.relative(projectDir, file);
88
+ };
89
+
90
+ const {decorateWriter} = manageCorking(this.reportStream);
158
91
  this.consumeStateChange = decorateWriter(this.consumeStateChange);
159
92
  this.endRun = decorateWriter(this.endRun);
160
93
 
161
- if (this.verbose) {
162
- this.durationThreshold = durationThreshold || 100;
163
- this.spinner = null;
164
- this.clearSpinner = () => {};
165
- this.lineWriter = new LineWriter(this.reportStream);
166
- } else {
167
- this.spinner = ora({
168
- isEnabled: true,
169
- color: spinner ? spinner.color : 'gray',
170
- discardStdin: !watching,
171
- hideCursor: false,
172
- spinner: spinner || (process.platform === 'win32' ? 'line' : 'dots'),
173
- stream: reportStream
174
- });
175
- this.clearSpinner = decorateFlushingWriter(this.spinner.clear.bind(this.spinner));
176
- this.lineWriter = new LineWriterWithSpinner(this.reportStream, this.spinner);
177
- }
94
+ this.durationThreshold = durationThreshold || 100;
95
+ this.lineWriter = new LineWriter(this.reportStream);
178
96
 
179
97
  this.reset();
180
98
  }
@@ -198,7 +116,6 @@ class Reporter {
198
116
  this.sharedWorkerErrors = [];
199
117
  this.uncaughtExceptions = [];
200
118
  this.unhandledRejections = [];
201
- this.unsavedSnapshots = [];
202
119
 
203
120
  this.previousFailures = 0;
204
121
 
@@ -221,9 +138,10 @@ class Reporter {
221
138
  this.matching = plan.matching;
222
139
  this.previousFailures = plan.previousFailures;
223
140
  this.emptyParallelRun = plan.status.emptyParallelRun;
141
+ this.selectionInsights = plan.status.selectionInsights;
224
142
 
225
143
  if (this.watching || plan.files.length > 1) {
226
- this.prefixTitle = (testFile, title) => prefixTitle(plan.filePathPrefix, testFile, title);
144
+ this.prefixTitle = (testFile, title) => prefixTitle(this.extensions, plan.filePathPrefix, testFile, title);
227
145
  }
228
146
 
229
147
  this.removePreviousListener = plan.status.on('stateChange', evt => {
@@ -234,13 +152,7 @@ class Reporter {
234
152
  this.lineWriter.write(chalk.gray.dim('\u2500'.repeat(this.lineWriter.columns)) + os.EOL);
235
153
  }
236
154
 
237
- if (this.spinner === null) {
238
- this.lineWriter.writeLine();
239
- } else {
240
- cliCursor.hide(this.reportStream);
241
- this.lineWriter.writeLine();
242
- this.spinner.start();
243
- }
155
+ this.lineWriter.writeLine();
244
156
  }
245
157
 
246
158
  consumeStateChange(event) { // eslint-disable-line complexity
@@ -296,12 +208,10 @@ class Reporter {
296
208
  this.write(colors.error(`${figures.cross} Internal error`));
297
209
  }
298
210
 
299
- if (this.verbose) {
300
- this.lineWriter.writeLine(colors.stack(event.err.summary));
301
- this.lineWriter.writeLine(colors.errorStack(event.err.stack));
302
- this.lineWriter.writeLine();
303
- this.lineWriter.writeLine();
304
- }
211
+ this.lineWriter.writeLine(colors.stack(event.err.summary));
212
+ this.lineWriter.writeLine(colors.errorStack(event.err.stack));
213
+ this.lineWriter.writeLine();
214
+ this.lineWriter.writeLine();
305
215
 
306
216
  break;
307
217
  }
@@ -321,7 +231,7 @@ class Reporter {
321
231
  }
322
232
 
323
233
  case 'hook-finished': {
324
- if (this.verbose && event.logs.length > 0) {
234
+ if (true && event.logs.length > 0) {
325
235
  this.lineWriter.writeLine(` ${this.prefixTitle(event.testFile, event.title)}`);
326
236
  this.writeLogs(event);
327
237
  }
@@ -330,12 +240,10 @@ class Reporter {
330
240
  }
331
241
 
332
242
  case 'selected-test': {
333
- if (this.verbose) {
334
- if (event.skip) {
335
- this.lineWriter.writeLine(colors.skip(`- ${this.prefixTitle(event.testFile, event.title)}`));
336
- } else if (event.todo) {
337
- this.lineWriter.writeLine(colors.todo(`- ${this.prefixTitle(event.testFile, event.title)}`));
338
- }
243
+ if (event.skip) {
244
+ this.lineWriter.writeLine(colors.skip(`- ${this.prefixTitle(event.testFile, event.title)}`));
245
+ } else if (event.todo) {
246
+ this.lineWriter.writeLine(colors.todo(`- ${this.prefixTitle(event.testFile, event.title)}`));
339
247
  }
340
248
 
341
249
  break;
@@ -344,29 +252,21 @@ class Reporter {
344
252
  case 'shared-worker-error': {
345
253
  this.sharedWorkerErrors.push(event);
346
254
 
347
- if (this.verbose) {
348
- this.lineWriter.ensureEmptyLine();
349
- this.lineWriter.writeLine(colors.error(`${figures.cross} Error in shared worker`));
350
- this.lineWriter.writeLine();
351
- this.writeErr(event);
352
- }
255
+ this.lineWriter.ensureEmptyLine();
256
+ this.lineWriter.writeLine(colors.error(`${figures.cross} Error in shared worker`));
257
+ this.lineWriter.writeLine();
258
+ this.writeErr(event);
353
259
 
354
260
  break;
355
261
  }
356
262
 
357
- case 'snapshot-error':
358
- this.unsavedSnapshots.push(event);
359
- break;
360
-
361
263
  case 'uncaught-exception': {
362
264
  this.uncaughtExceptions.push(event);
363
265
 
364
- if (this.verbose) {
365
- this.lineWriter.ensureEmptyLine();
366
- this.lineWriter.writeLine(colors.title(`Uncaught exception in ${this.relativeFile(event.testFile)}`));
367
- this.lineWriter.writeLine();
368
- this.writeErr(event);
369
- }
266
+ this.lineWriter.ensureEmptyLine();
267
+ this.lineWriter.writeLine(colors.title(`Uncaught exception in ${this.relativeFile(event.testFile)}`));
268
+ this.lineWriter.writeLine();
269
+ this.writeErr(event);
370
270
 
371
271
  break;
372
272
  }
@@ -374,12 +274,10 @@ class Reporter {
374
274
  case 'unhandled-rejection': {
375
275
  this.unhandledRejections.push(event);
376
276
 
377
- if (this.verbose) {
378
- this.lineWriter.ensureEmptyLine();
379
- this.lineWriter.writeLine(colors.title(`Unhandled rejection in ${this.relativeFile(event.testFile)}`));
380
- this.lineWriter.writeLine();
381
- this.writeErr(event);
382
- }
277
+ this.lineWriter.ensureEmptyLine();
278
+ this.lineWriter.writeLine(colors.title(`Unhandled rejection in ${this.relativeFile(event.testFile)}`));
279
+ this.lineWriter.writeLine();
280
+ this.writeErr(event);
383
281
 
384
282
  break;
385
283
  }
@@ -389,8 +287,12 @@ class Reporter {
389
287
  this.filesWithoutDeclaredTests.add(event.testFile);
390
288
  }
391
289
 
392
- if (this.verbose && !this.filesWithMissingAvaImports.has(event.testFile)) {
393
- if (event.nonZeroExitCode) {
290
+ if (!this.filesWithMissingAvaImports.has(event.testFile)) {
291
+ if (event.err) {
292
+ this.lineWriter.writeLine(colors.error(`${figures.cross} ${this.relativeFile(event.testFile)} exited due to an error:`));
293
+ this.lineWriter.writeLine();
294
+ this.writeErr(event);
295
+ } else if (event.nonZeroExitCode) {
394
296
  this.lineWriter.writeLine(colors.error(`${figures.cross} ${this.relativeFile(event.testFile)} exited with a non-zero exit code: ${event.nonZeroExitCode}`));
395
297
  } else {
396
298
  this.lineWriter.writeLine(colors.error(`${figures.cross} ${this.relativeFile(event.testFile)} exited due to ${event.signal}`));
@@ -410,7 +312,7 @@ class Reporter {
410
312
  this.filesWithoutMatchedLineNumbers.add(event.testFile);
411
313
 
412
314
  this.lineWriter.writeLine(colors.error(`${figures.cross} Line numbers for ${this.relativeFile(event.testFile)} did not match any tests`));
413
- } else if (this.verbose && !this.failFastEnabled && fileStats.remainingTests > 0) {
315
+ } else if (true && !this.failFastEnabled && fileStats.remainingTests > 0) {
414
316
  this.lineWriter.writeLine(colors.error(`${figures.cross} ${fileStats.remainingTests} ${plur('test', fileStats.remainingTests)} remaining in ${this.relativeFile(event.testFile)}`));
415
317
  }
416
318
  }
@@ -419,9 +321,6 @@ class Reporter {
419
321
  }
420
322
 
421
323
  case 'worker-stderr': {
422
- // Forcibly clear the spinner, writing the chunk corrupts the TTY.
423
- this.clearSpinner();
424
-
425
324
  this.stdStream.write(event.chunk);
426
325
  // If the chunk does not end with a linebreak, *forcibly* write one to
427
326
  // ensure it remains visible in the TTY.
@@ -433,17 +332,10 @@ class Reporter {
433
332
  this.reportStream.write(os.EOL);
434
333
  }
435
334
 
436
- if (this.spinner !== null) {
437
- this.lineWriter.write(this.lineWriter.lastSpinnerText);
438
- }
439
-
440
335
  break;
441
336
  }
442
337
 
443
338
  case 'worker-stdout': {
444
- // Forcibly clear the spinner, writing the chunk corrupts the TTY.
445
- this.clearSpinner();
446
-
447
339
  this.stdStream.write(event.chunk);
448
340
  // If the chunk does not end with a linebreak, *forcibly* write one to
449
341
  // ensure it remains visible in the TTY.
@@ -454,10 +346,6 @@ class Reporter {
454
346
  if (event.chunk[event.chunk.length - 1] !== 0x0A) {
455
347
  this.reportStream.write(os.EOL);
456
348
  }
457
-
458
- if (this.spinner !== null) {
459
- this.lineWriter.write(this.lineWriter.lastSpinnerText);
460
- }
461
349
  }
462
350
  }
463
351
  }
@@ -478,11 +366,7 @@ class Reporter {
478
366
  }
479
367
 
480
368
  write(string) {
481
- if (this.verbose) {
482
- this.lineWriter.writeLine(string);
483
- } else {
484
- this.writeWithCounts(string);
485
- }
369
+ this.lineWriter.writeLine(string);
486
370
  }
487
371
 
488
372
  writeWithCounts(string) {
@@ -529,7 +413,7 @@ class Reporter {
529
413
 
530
414
  writeErr(event) {
531
415
  if (event.err.name === 'TSError' && event.err.object && event.err.object.diagnosticText) {
532
- this.lineWriter.writeLine(colors.errorStack(trimOffNewlines(event.err.object.diagnosticText)));
416
+ this.lineWriter.writeLine(colors.errorStack(event.err.object.diagnosticText));
533
417
  this.lineWriter.writeLine();
534
418
  return;
535
419
  }
@@ -556,13 +440,13 @@ class Reporter {
556
440
  this.lineWriter.writeLine();
557
441
  }
558
442
 
559
- const message = improperUsageMessages.forError(event.err);
443
+ const message = improperUsageMessage(event.err);
560
444
  if (message) {
561
445
  this.lineWriter.writeLine(message);
562
446
  this.lineWriter.writeLine();
563
447
  }
564
448
  } else if (event.err.nonErrorObject) {
565
- this.lineWriter.writeLine(trimOffNewlines(event.err.formatted));
449
+ this.lineWriter.writeLine(event.err.formatted);
566
450
  this.lineWriter.writeLine();
567
451
  } else {
568
452
  this.lineWriter.writeLine(event.err.summary);
@@ -618,27 +502,15 @@ class Reporter {
618
502
 
619
503
  writeTestSummary(event) {
620
504
  if (event.type === 'hook-failed' || event.type === 'test-failed') {
621
- if (this.verbose) {
622
- this.write(`${colors.error(figures.cross)} ${this.prefixTitle(event.testFile, event.title)} ${colors.error(event.err.message)}`);
623
- } else {
624
- this.write(this.prefixTitle(event.testFile, event.title));
625
- }
505
+ this.write(`${colors.error(figures.cross)} ${this.prefixTitle(event.testFile, event.title)} ${colors.error(event.err.message)}`);
626
506
  } else if (event.knownFailing) {
627
- if (this.verbose) {
628
- this.write(`${colors.error(figures.tick)} ${colors.error(this.prefixTitle(event.testFile, event.title))}`);
629
- } else {
630
- this.write(colors.error(this.prefixTitle(event.testFile, event.title)));
631
- }
632
- } else if (this.verbose) {
507
+ this.write(`${colors.error(figures.tick)} ${colors.error(this.prefixTitle(event.testFile, event.title))}`);
508
+ } else {
633
509
  const duration = event.duration > this.durationThreshold ? colors.duration(' (' + prettyMs(event.duration) + ')') : '';
634
510
  this.write(`${colors.pass(figures.tick)} ${this.prefixTitle(event.testFile, event.title)}${duration}`);
635
- } else {
636
- this.write(this.prefixTitle(event.testFile, event.title));
637
511
  }
638
512
 
639
- if (this.verbose) {
640
- this.writeLogs(event);
641
- }
513
+ this.writeLogs(event);
642
514
  }
643
515
 
644
516
  writeFailure(event) {
@@ -652,77 +524,51 @@ class Reporter {
652
524
 
653
525
  endRun() {// eslint-disable-line complexity
654
526
  let firstLinePostfix = this.watching ? ` ${chalk.gray.dim(`[${new Date().toLocaleTimeString('en-US', {hour12: false})}]`)}` : '';
655
- let wroteSomething = false;
656
527
 
657
- if (!this.verbose) {
658
- this.spinner.stop();
659
- cliCursor.show(this.reportStream);
660
- } else if (this.emptyParallelRun) {
528
+ if (this.emptyParallelRun) {
661
529
  this.lineWriter.writeLine('No files tested in this parallel run');
662
530
  this.lineWriter.writeLine();
663
531
  return;
664
532
  }
665
533
 
666
- if (!this.stats) {
667
- this.lineWriter.writeLine(colors.error(`${figures.cross} Couldn’t find any files to test` + firstLinePostfix));
534
+ if (this.selectionInsights.ignoredFilterPatternFiles.length > 0) {
535
+ this.write(colors.information(`${figures.warning} Paths for additional test files were disregarded:`));
668
536
  this.lineWriter.writeLine();
669
- return;
670
- }
537
+ for (const pattern of this.selectionInsights.ignoredFilterPatternFiles) {
538
+ this.lineWriter.writeLine(chalk.magenta(`* ${pattern}`));
539
+ }
671
540
 
672
- if (this.matching && this.stats.selectedTests === 0) {
673
- this.lineWriter.writeLine(colors.error(`${figures.cross} Couldn’t find any matching tests` + firstLinePostfix));
674
541
  this.lineWriter.writeLine();
675
- return;
676
- }
677
-
678
- if (this.verbose) {
679
- this.lineWriter.writeLine(colors.log(figures.line));
542
+ this.write(colors.information('Files starting with underscores are never treated as test files.'));
543
+ this.write(colors.information('Files handled by @ava/typescript can only be selected if your configuration already selects them.'));
680
544
  this.lineWriter.writeLine();
681
- } else {
682
- if (this.filesWithMissingAvaImports.size > 0) {
683
- for (const testFile of this.filesWithMissingAvaImports) {
684
- this.lineWriter.writeLine(colors.error(`${figures.cross} No tests found in ${this.relativeFile(testFile)}, make sure to import "ava" at the top of your test file`) + firstLinePostfix);
685
- firstLinePostfix = '';
686
- wroteSomething = true;
687
- }
688
- }
689
-
690
- if (this.filesWithoutDeclaredTests.size > 0) {
691
- for (const testFile of this.filesWithoutDeclaredTests) {
692
- if (!this.filesWithMissingAvaImports.has(testFile)) {
693
- this.lineWriter.writeLine(colors.error(`${figures.cross} No tests found in ${this.relativeFile(testFile)}`) + firstLinePostfix);
694
- firstLinePostfix = '';
695
- wroteSomething = true;
696
- }
697
- }
698
- }
545
+ }
699
546
 
700
- if (this.lineNumberErrors.length > 0) {
701
- for (const event of this.lineNumberErrors) {
702
- this.lineWriter.writeLine(colors.information(`${figures.warning} Could not parse ${this.relativeFile(event.testFile)} for line number selection` + firstLinePostfix));
703
- firstLinePostfix = '';
704
- wroteSomething = true;
547
+ if (this.selectionInsights.selectionCount === 0) {
548
+ if (this.selectionInsights.testFileCount === 0) {
549
+ this.lineWriter.writeLine(colors.error(`${figures.cross} Couldn’t find any files to test` + firstLinePostfix));
550
+ } else {
551
+ const {testFileCount: count} = this.selectionInsights;
552
+ this.lineWriter.writeLine(colors.error(`${figures.cross} Based on your configuration, ${count} test ${plur('file was', 'files were', count)} found, but did not match the CLI arguments:` + firstLinePostfix));
553
+ this.lineWriter.writeLine();
554
+ for (const {pattern} of this.selectionInsights.filter) {
555
+ this.lineWriter.writeLine(colors.error(`* ${pattern}`));
705
556
  }
706
557
  }
707
558
 
708
- if (this.filesWithoutMatchedLineNumbers.size > 0) {
709
- for (const testFile of this.filesWithoutMatchedLineNumbers) {
710
- if (!this.filesWithMissingAvaImports.has(testFile) && !this.filesWithoutDeclaredTests.has(testFile)) {
711
- this.lineWriter.writeLine(colors.error(`${figures.cross} Line numbers for ${this.relativeFile(testFile)} did not match any tests`) + firstLinePostfix);
712
- firstLinePostfix = '';
713
- wroteSomething = true;
714
- }
715
- }
716
- }
559
+ this.lineWriter.writeLine();
560
+ return;
561
+ }
717
562
 
718
- if (wroteSomething) {
719
- this.lineWriter.writeLine();
720
- this.lineWriter.writeLine(colors.log(figures.line));
721
- this.lineWriter.writeLine();
722
- wroteSomething = false;
723
- }
563
+ if (this.matching && this.stats.selectedTests === 0) {
564
+ this.lineWriter.writeLine(colors.error(`${figures.cross} Couldn’t find any matching tests` + firstLinePostfix));
565
+ this.lineWriter.writeLine();
566
+ return;
724
567
  }
725
568
 
569
+ this.lineWriter.writeLine(colors.log(figures.line));
570
+ this.lineWriter.writeLine();
571
+
726
572
  if (this.failures.length > 0) {
727
573
  const writeTrailingLines = this.internalErrors.length > 0 || this.sharedWorkerErrors.length > 0 || this.uncaughtExceptions.length > 0 || this.unhandledRejections.length > 0;
728
574
 
@@ -732,106 +578,13 @@ class Reporter {
732
578
  if (event !== lastFailure) {
733
579
  this.lineWriter.writeLine();
734
580
  this.lineWriter.writeLine();
735
- } else if (!this.verbose && writeTrailingLines) {
581
+ } else if (!true && writeTrailingLines) {
736
582
  this.lineWriter.writeLine();
737
583
  this.lineWriter.writeLine();
738
584
  }
739
-
740
- wroteSomething = true;
741
- }
742
-
743
- if (this.verbose) {
744
- this.lineWriter.writeLine(colors.log(figures.line));
745
- this.lineWriter.writeLine();
746
- }
747
- }
748
-
749
- if (!this.verbose) {
750
- if (this.internalErrors.length > 0) {
751
- const writeTrailingLines = this.sharedWorkerErrors.length > 0 || this.uncaughtExceptions.length > 0 || this.unhandledRejections.length > 0;
752
-
753
- const last = this.internalErrors[this.internalErrors.length - 1];
754
- for (const event of this.internalErrors) {
755
- if (event.testFile) {
756
- this.lineWriter.writeLine(colors.error(`${figures.cross} Internal error when running ${this.relativeFile(event.testFile)}`));
757
- } else {
758
- this.lineWriter.writeLine(colors.error(`${figures.cross} Internal error`));
759
- }
760
-
761
- this.lineWriter.writeLine(colors.stack(event.err.summary));
762
- this.lineWriter.writeLine(colors.errorStack(event.err.stack));
763
- if (event !== last || writeTrailingLines) {
764
- this.lineWriter.writeLine();
765
- this.lineWriter.writeLine();
766
- this.lineWriter.writeLine();
767
- }
768
-
769
- wroteSomething = true;
770
- }
771
- }
772
-
773
- if (this.sharedWorkerErrors.length > 0) {
774
- const writeTrailingLines = this.uncaughtExceptions.length > 0 || this.unhandledRejections.length > 0;
775
-
776
- const last = this.sharedWorkerErrors[this.sharedWorkerErrors.length - 1];
777
- for (const evt of this.sharedWorkerErrors) {
778
- this.lineWriter.writeLine(colors.error(`${figures.cross} Error in shared worker`));
779
- this.lineWriter.writeLine();
780
- this.writeErr(evt.err);
781
- if (evt !== last || writeTrailingLines) {
782
- this.lineWriter.writeLine();
783
- this.lineWriter.writeLine();
784
- }
785
-
786
- wroteSomething = true;
787
- }
788
- }
789
-
790
- if (this.uncaughtExceptions.length > 0) {
791
- const writeTrailingLines = this.unhandledRejections.length > 0;
792
-
793
- const last = this.uncaughtExceptions[this.uncaughtExceptions.length - 1];
794
- for (const event of this.uncaughtExceptions) {
795
- this.lineWriter.writeLine(colors.title(`Uncaught exception in ${this.relativeFile(event.testFile)}`));
796
- this.lineWriter.writeLine();
797
- this.writeErr(event);
798
- if (event !== last || writeTrailingLines) {
799
- this.lineWriter.writeLine();
800
- this.lineWriter.writeLine();
801
- }
802
-
803
- wroteSomething = true;
804
- }
805
- }
806
-
807
- if (this.unhandledRejections.length > 0) {
808
- const last = this.unhandledRejections[this.unhandledRejections.length - 1];
809
- for (const event of this.unhandledRejections) {
810
- this.lineWriter.writeLine(colors.title(`Unhandled rejection in ${this.relativeFile(event.testFile)}`));
811
- this.lineWriter.writeLine();
812
- this.writeErr(event);
813
- if (event !== last) {
814
- this.lineWriter.writeLine();
815
- this.lineWriter.writeLine();
816
- }
817
-
818
- wroteSomething = true;
819
- }
820
- }
821
-
822
- if (wroteSomething) {
823
- this.lineWriter.writeLine(colors.log(figures.line));
824
- this.lineWriter.writeLine();
825
- }
826
- }
827
-
828
- if (this.unsavedSnapshots.length > 0) {
829
- this.lineWriter.writeLine(colors.title('Could not update snapshots for the following test files:'));
830
- this.lineWriter.writeLine();
831
- for (const event of this.unsavedSnapshots) {
832
- this.lineWriter.writeLine(`${figures.warning} ${this.relativeFile(event.testFile)}`);
833
585
  }
834
586
 
587
+ this.lineWriter.writeLine(colors.log(figures.line));
835
588
  this.lineWriter.writeLine();
836
589
  }
837
590
 
@@ -853,16 +606,14 @@ class Reporter {
853
606
  }
854
607
 
855
608
  this.lineWriter.writeLine(colors.information(`\`--fail-fast\` is on. ${remaining}.`));
856
- if (this.verbose) {
857
- this.lineWriter.writeLine();
858
- }
609
+ this.lineWriter.writeLine();
859
610
  }
860
611
 
861
- if (this.verbose && this.stats.parallelRuns) {
612
+ if (this.stats.parallelRuns) {
862
613
  const {
863
614
  currentFileCount,
864
615
  currentIndex,
865
- totalRuns
616
+ totalRuns,
866
617
  } = this.stats.parallelRuns;
867
618
  this.lineWriter.writeLine(colors.information(`Ran ${currentFileCount} test ${plur('file', currentFileCount)} out of ${this.stats.files} for job ${currentIndex + 1} of ${totalRuns}`));
868
619
  this.lineWriter.writeLine();
@@ -879,11 +630,11 @@ class Reporter {
879
630
  }
880
631
 
881
632
  if (
882
- this.stats.failedHooks === 0 &&
883
- this.stats.failedTests === 0 &&
884
- this.stats.passedTests > 0
633
+ this.stats.failedHooks === 0
634
+ && this.stats.failedTests === 0
635
+ && this.stats.passedTests > 0
885
636
  ) {
886
- this.lineWriter.writeLine(colors.pass(`${this.stats.passedTests} ${plur('test', this.stats.passedTests)} passed`) + firstLinePostfix
637
+ this.lineWriter.writeLine(colors.pass(`${this.stats.passedTests} ${plur('test', this.stats.passedTests)} passed`) + firstLinePostfix,
887
638
  );
888
639
  firstLinePostfix = '';
889
640
  }
@@ -917,4 +668,3 @@ class Reporter {
917
668
  }
918
669
  }
919
670
  }
920
- module.exports = Reporter;