ava 4.0.0-alpha.1 → 4.0.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/entrypoints/cli.mjs +4 -0
- package/{eslint-plugin-helper.js → entrypoints/eslint-plugin-helper.cjs} +20 -7
- package/entrypoints/main.cjs +2 -0
- package/entrypoints/main.mjs +1 -0
- package/entrypoints/plugin.cjs +2 -0
- package/entrypoints/plugin.mjs +4 -0
- package/index.d.ts +6 -709
- package/lib/api.js +95 -46
- package/lib/assert.js +122 -173
- package/lib/chalk.js +9 -14
- package/lib/cli.js +105 -97
- package/lib/code-excerpt.js +12 -17
- package/lib/concordance-options.js +30 -31
- package/lib/context-ref.js +3 -6
- package/lib/create-chain.js +32 -4
- package/lib/environment-variables.js +1 -4
- package/lib/eslint-plugin-helper-worker.js +16 -26
- package/lib/extensions.js +2 -2
- package/lib/fork.js +42 -83
- package/lib/glob-helpers.cjs +140 -0
- package/lib/globs.js +136 -163
- package/lib/{ipc-flow-control.js → ipc-flow-control.cjs} +1 -0
- package/lib/is-ci.js +4 -2
- package/lib/like-selector.js +7 -13
- package/lib/line-numbers.js +10 -17
- package/lib/load-config.js +62 -56
- package/lib/module-types.js +3 -3
- package/lib/node-arguments.js +4 -5
- package/lib/{now-and-timers.js → now-and-timers.cjs} +0 -0
- package/lib/parse-test-args.js +22 -11
- package/lib/pkg.cjs +2 -0
- package/lib/plugin-support/shared-worker-loader.js +45 -48
- package/lib/plugin-support/shared-workers.js +24 -43
- package/lib/provider-manager.js +20 -14
- package/lib/reporters/beautify-stack.js +6 -11
- package/lib/reporters/colors.js +40 -15
- package/lib/reporters/default.js +115 -350
- package/lib/reporters/format-serialized-error.js +7 -18
- package/lib/reporters/improper-usage-messages.js +8 -9
- package/lib/reporters/prefix-title.js +17 -15
- package/lib/reporters/tap.js +15 -16
- package/lib/run-status.js +25 -23
- package/lib/runner.js +138 -127
- package/lib/scheduler.js +42 -36
- package/lib/serialize-error.js +34 -34
- package/lib/snapshot-manager.js +83 -76
- package/lib/test.js +114 -195
- package/lib/watcher.js +65 -40
- package/lib/worker/base.js +48 -99
- package/lib/worker/channel.cjs +290 -0
- package/lib/worker/dependency-tracker.js +22 -22
- package/lib/worker/guard-environment.cjs +19 -0
- package/lib/worker/line-numbers.js +57 -19
- package/lib/worker/main.cjs +12 -0
- package/lib/worker/{options.js → options.cjs} +0 -0
- package/lib/worker/{plugin.js → plugin.cjs} +31 -16
- package/lib/worker/state.cjs +5 -0
- package/lib/worker/{utils.js → utils.cjs} +1 -1
- package/package.json +60 -68
- package/plugin.d.ts +51 -53
- package/readme.md +5 -12
- package/types/assertions.d.ts +327 -0
- package/types/subscribable.ts +6 -0
- package/types/test-fn.d.ts +231 -0
- package/types/try-fn.d.ts +58 -0
- package/cli.js +0 -11
- package/index.js +0 -8
- package/lib/worker/channel.js +0 -218
- package/lib/worker/main.js +0 -20
- package/plugin.js +0 -9
package/lib/reporters/default.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
71
|
+
extensions,
|
|
144
72
|
reportStream,
|
|
145
73
|
stdStream,
|
|
146
74
|
projectDir,
|
|
147
75
|
watching,
|
|
148
|
-
|
|
149
|
-
durationThreshold
|
|
76
|
+
durationThreshold,
|
|
150
77
|
}) {
|
|
151
|
-
this.
|
|
78
|
+
this.extensions = extensions;
|
|
152
79
|
this.reportStream = reportStream;
|
|
153
80
|
this.stdStream = stdStream;
|
|
154
81
|
this.watching = watching;
|
|
155
|
-
this.relativeFile = file =>
|
|
82
|
+
this.relativeFile = file => {
|
|
83
|
+
if (file.startsWith('file://')) {
|
|
84
|
+
file = fileURLToPath(file);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return path.relative(projectDir, file);
|
|
88
|
+
};
|
|
156
89
|
|
|
157
|
-
const {decorateWriter
|
|
90
|
+
const {decorateWriter} = manageCorking(this.reportStream);
|
|
158
91
|
this.consumeStateChange = decorateWriter(this.consumeStateChange);
|
|
159
92
|
this.endRun = decorateWriter(this.endRun);
|
|
160
93
|
|
|
161
|
-
|
|
162
|
-
|
|
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
|
}
|
|
@@ -220,9 +138,10 @@ class Reporter {
|
|
|
220
138
|
this.matching = plan.matching;
|
|
221
139
|
this.previousFailures = plan.previousFailures;
|
|
222
140
|
this.emptyParallelRun = plan.status.emptyParallelRun;
|
|
141
|
+
this.selectionInsights = plan.status.selectionInsights;
|
|
223
142
|
|
|
224
143
|
if (this.watching || plan.files.length > 1) {
|
|
225
|
-
this.prefixTitle = (testFile, title) => prefixTitle(plan.filePathPrefix, testFile, title);
|
|
144
|
+
this.prefixTitle = (testFile, title) => prefixTitle(this.extensions, plan.filePathPrefix, testFile, title);
|
|
226
145
|
}
|
|
227
146
|
|
|
228
147
|
this.removePreviousListener = plan.status.on('stateChange', evt => {
|
|
@@ -233,13 +152,7 @@ class Reporter {
|
|
|
233
152
|
this.lineWriter.write(chalk.gray.dim('\u2500'.repeat(this.lineWriter.columns)) + os.EOL);
|
|
234
153
|
}
|
|
235
154
|
|
|
236
|
-
|
|
237
|
-
this.lineWriter.writeLine();
|
|
238
|
-
} else {
|
|
239
|
-
cliCursor.hide(this.reportStream);
|
|
240
|
-
this.lineWriter.writeLine();
|
|
241
|
-
this.spinner.start();
|
|
242
|
-
}
|
|
155
|
+
this.lineWriter.writeLine();
|
|
243
156
|
}
|
|
244
157
|
|
|
245
158
|
consumeStateChange(event) { // eslint-disable-line complexity
|
|
@@ -295,12 +208,10 @@ class Reporter {
|
|
|
295
208
|
this.write(colors.error(`${figures.cross} Internal error`));
|
|
296
209
|
}
|
|
297
210
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
this.lineWriter.writeLine();
|
|
303
|
-
}
|
|
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();
|
|
304
215
|
|
|
305
216
|
break;
|
|
306
217
|
}
|
|
@@ -320,7 +231,7 @@ class Reporter {
|
|
|
320
231
|
}
|
|
321
232
|
|
|
322
233
|
case 'hook-finished': {
|
|
323
|
-
if (
|
|
234
|
+
if (true && event.logs.length > 0) {
|
|
324
235
|
this.lineWriter.writeLine(` ${this.prefixTitle(event.testFile, event.title)}`);
|
|
325
236
|
this.writeLogs(event);
|
|
326
237
|
}
|
|
@@ -329,12 +240,10 @@ class Reporter {
|
|
|
329
240
|
}
|
|
330
241
|
|
|
331
242
|
case 'selected-test': {
|
|
332
|
-
if (
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
this.lineWriter.writeLine(colors.todo(`- ${this.prefixTitle(event.testFile, event.title)}`));
|
|
337
|
-
}
|
|
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)}`));
|
|
338
247
|
}
|
|
339
248
|
|
|
340
249
|
break;
|
|
@@ -343,12 +252,10 @@ class Reporter {
|
|
|
343
252
|
case 'shared-worker-error': {
|
|
344
253
|
this.sharedWorkerErrors.push(event);
|
|
345
254
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
this.writeErr(event);
|
|
351
|
-
}
|
|
255
|
+
this.lineWriter.ensureEmptyLine();
|
|
256
|
+
this.lineWriter.writeLine(colors.error(`${figures.cross} Error in shared worker`));
|
|
257
|
+
this.lineWriter.writeLine();
|
|
258
|
+
this.writeErr(event);
|
|
352
259
|
|
|
353
260
|
break;
|
|
354
261
|
}
|
|
@@ -356,12 +263,10 @@ class Reporter {
|
|
|
356
263
|
case 'uncaught-exception': {
|
|
357
264
|
this.uncaughtExceptions.push(event);
|
|
358
265
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
this.writeErr(event);
|
|
364
|
-
}
|
|
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);
|
|
365
270
|
|
|
366
271
|
break;
|
|
367
272
|
}
|
|
@@ -369,12 +274,10 @@ class Reporter {
|
|
|
369
274
|
case 'unhandled-rejection': {
|
|
370
275
|
this.unhandledRejections.push(event);
|
|
371
276
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
this.writeErr(event);
|
|
377
|
-
}
|
|
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);
|
|
378
281
|
|
|
379
282
|
break;
|
|
380
283
|
}
|
|
@@ -384,8 +287,12 @@ class Reporter {
|
|
|
384
287
|
this.filesWithoutDeclaredTests.add(event.testFile);
|
|
385
288
|
}
|
|
386
289
|
|
|
387
|
-
if (
|
|
388
|
-
if (event.
|
|
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) {
|
|
389
296
|
this.lineWriter.writeLine(colors.error(`${figures.cross} ${this.relativeFile(event.testFile)} exited with a non-zero exit code: ${event.nonZeroExitCode}`));
|
|
390
297
|
} else {
|
|
391
298
|
this.lineWriter.writeLine(colors.error(`${figures.cross} ${this.relativeFile(event.testFile)} exited due to ${event.signal}`));
|
|
@@ -405,7 +312,7 @@ class Reporter {
|
|
|
405
312
|
this.filesWithoutMatchedLineNumbers.add(event.testFile);
|
|
406
313
|
|
|
407
314
|
this.lineWriter.writeLine(colors.error(`${figures.cross} Line numbers for ${this.relativeFile(event.testFile)} did not match any tests`));
|
|
408
|
-
} else if (
|
|
315
|
+
} else if (true && !this.failFastEnabled && fileStats.remainingTests > 0) {
|
|
409
316
|
this.lineWriter.writeLine(colors.error(`${figures.cross} ${fileStats.remainingTests} ${plur('test', fileStats.remainingTests)} remaining in ${this.relativeFile(event.testFile)}`));
|
|
410
317
|
}
|
|
411
318
|
}
|
|
@@ -414,9 +321,6 @@ class Reporter {
|
|
|
414
321
|
}
|
|
415
322
|
|
|
416
323
|
case 'worker-stderr': {
|
|
417
|
-
// Forcibly clear the spinner, writing the chunk corrupts the TTY.
|
|
418
|
-
this.clearSpinner();
|
|
419
|
-
|
|
420
324
|
this.stdStream.write(event.chunk);
|
|
421
325
|
// If the chunk does not end with a linebreak, *forcibly* write one to
|
|
422
326
|
// ensure it remains visible in the TTY.
|
|
@@ -428,17 +332,10 @@ class Reporter {
|
|
|
428
332
|
this.reportStream.write(os.EOL);
|
|
429
333
|
}
|
|
430
334
|
|
|
431
|
-
if (this.spinner !== null) {
|
|
432
|
-
this.lineWriter.write(this.lineWriter.lastSpinnerText);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
335
|
break;
|
|
436
336
|
}
|
|
437
337
|
|
|
438
338
|
case 'worker-stdout': {
|
|
439
|
-
// Forcibly clear the spinner, writing the chunk corrupts the TTY.
|
|
440
|
-
this.clearSpinner();
|
|
441
|
-
|
|
442
339
|
this.stdStream.write(event.chunk);
|
|
443
340
|
// If the chunk does not end with a linebreak, *forcibly* write one to
|
|
444
341
|
// ensure it remains visible in the TTY.
|
|
@@ -449,10 +346,6 @@ class Reporter {
|
|
|
449
346
|
if (event.chunk[event.chunk.length - 1] !== 0x0A) {
|
|
450
347
|
this.reportStream.write(os.EOL);
|
|
451
348
|
}
|
|
452
|
-
|
|
453
|
-
if (this.spinner !== null) {
|
|
454
|
-
this.lineWriter.write(this.lineWriter.lastSpinnerText);
|
|
455
|
-
}
|
|
456
349
|
}
|
|
457
350
|
}
|
|
458
351
|
}
|
|
@@ -473,11 +366,7 @@ class Reporter {
|
|
|
473
366
|
}
|
|
474
367
|
|
|
475
368
|
write(string) {
|
|
476
|
-
|
|
477
|
-
this.lineWriter.writeLine(string);
|
|
478
|
-
} else {
|
|
479
|
-
this.writeWithCounts(string);
|
|
480
|
-
}
|
|
369
|
+
this.lineWriter.writeLine(string);
|
|
481
370
|
}
|
|
482
371
|
|
|
483
372
|
writeWithCounts(string) {
|
|
@@ -524,7 +413,7 @@ class Reporter {
|
|
|
524
413
|
|
|
525
414
|
writeErr(event) {
|
|
526
415
|
if (event.err.name === 'TSError' && event.err.object && event.err.object.diagnosticText) {
|
|
527
|
-
this.lineWriter.writeLine(colors.errorStack(
|
|
416
|
+
this.lineWriter.writeLine(colors.errorStack(event.err.object.diagnosticText));
|
|
528
417
|
this.lineWriter.writeLine();
|
|
529
418
|
return;
|
|
530
419
|
}
|
|
@@ -551,13 +440,13 @@ class Reporter {
|
|
|
551
440
|
this.lineWriter.writeLine();
|
|
552
441
|
}
|
|
553
442
|
|
|
554
|
-
const message =
|
|
443
|
+
const message = improperUsageMessage(event.err);
|
|
555
444
|
if (message) {
|
|
556
445
|
this.lineWriter.writeLine(message);
|
|
557
446
|
this.lineWriter.writeLine();
|
|
558
447
|
}
|
|
559
448
|
} else if (event.err.nonErrorObject) {
|
|
560
|
-
this.lineWriter.writeLine(
|
|
449
|
+
this.lineWriter.writeLine(event.err.formatted);
|
|
561
450
|
this.lineWriter.writeLine();
|
|
562
451
|
} else {
|
|
563
452
|
this.lineWriter.writeLine(event.err.summary);
|
|
@@ -613,27 +502,15 @@ class Reporter {
|
|
|
613
502
|
|
|
614
503
|
writeTestSummary(event) {
|
|
615
504
|
if (event.type === 'hook-failed' || event.type === 'test-failed') {
|
|
616
|
-
|
|
617
|
-
this.write(`${colors.error(figures.cross)} ${this.prefixTitle(event.testFile, event.title)} ${colors.error(event.err.message)}`);
|
|
618
|
-
} else {
|
|
619
|
-
this.write(this.prefixTitle(event.testFile, event.title));
|
|
620
|
-
}
|
|
505
|
+
this.write(`${colors.error(figures.cross)} ${this.prefixTitle(event.testFile, event.title)} ${colors.error(event.err.message)}`);
|
|
621
506
|
} else if (event.knownFailing) {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
} else {
|
|
625
|
-
this.write(colors.error(this.prefixTitle(event.testFile, event.title)));
|
|
626
|
-
}
|
|
627
|
-
} else if (this.verbose) {
|
|
507
|
+
this.write(`${colors.error(figures.tick)} ${colors.error(this.prefixTitle(event.testFile, event.title))}`);
|
|
508
|
+
} else {
|
|
628
509
|
const duration = event.duration > this.durationThreshold ? colors.duration(' (' + prettyMs(event.duration) + ')') : '';
|
|
629
510
|
this.write(`${colors.pass(figures.tick)} ${this.prefixTitle(event.testFile, event.title)}${duration}`);
|
|
630
|
-
} else {
|
|
631
|
-
this.write(this.prefixTitle(event.testFile, event.title));
|
|
632
511
|
}
|
|
633
512
|
|
|
634
|
-
|
|
635
|
-
this.writeLogs(event);
|
|
636
|
-
}
|
|
513
|
+
this.writeLogs(event);
|
|
637
514
|
}
|
|
638
515
|
|
|
639
516
|
writeFailure(event) {
|
|
@@ -647,77 +524,51 @@ class Reporter {
|
|
|
647
524
|
|
|
648
525
|
endRun() {// eslint-disable-line complexity
|
|
649
526
|
let firstLinePostfix = this.watching ? ` ${chalk.gray.dim(`[${new Date().toLocaleTimeString('en-US', {hour12: false})}]`)}` : '';
|
|
650
|
-
let wroteSomething = false;
|
|
651
527
|
|
|
652
|
-
if (
|
|
653
|
-
this.spinner.stop();
|
|
654
|
-
cliCursor.show(this.reportStream);
|
|
655
|
-
} else if (this.emptyParallelRun) {
|
|
528
|
+
if (this.emptyParallelRun) {
|
|
656
529
|
this.lineWriter.writeLine('No files tested in this parallel run');
|
|
657
530
|
this.lineWriter.writeLine();
|
|
658
531
|
return;
|
|
659
532
|
}
|
|
660
533
|
|
|
661
|
-
if (
|
|
662
|
-
this.
|
|
534
|
+
if (this.selectionInsights.ignoredFilterPatternFiles.length > 0) {
|
|
535
|
+
this.write(colors.information(`${figures.warning} Paths for additional test files were disregarded:`));
|
|
663
536
|
this.lineWriter.writeLine();
|
|
664
|
-
|
|
665
|
-
|
|
537
|
+
for (const pattern of this.selectionInsights.ignoredFilterPatternFiles) {
|
|
538
|
+
this.lineWriter.writeLine(chalk.magenta(`* ${pattern}`));
|
|
539
|
+
}
|
|
666
540
|
|
|
667
|
-
if (this.matching && this.stats.selectedTests === 0) {
|
|
668
|
-
this.lineWriter.writeLine(colors.error(`${figures.cross} Couldn’t find any matching tests` + firstLinePostfix));
|
|
669
541
|
this.lineWriter.writeLine();
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
if (this.verbose) {
|
|
674
|
-
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.'));
|
|
675
544
|
this.lineWriter.writeLine();
|
|
676
|
-
}
|
|
677
|
-
if (this.filesWithMissingAvaImports.size > 0) {
|
|
678
|
-
for (const testFile of this.filesWithMissingAvaImports) {
|
|
679
|
-
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);
|
|
680
|
-
firstLinePostfix = '';
|
|
681
|
-
wroteSomething = true;
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
if (this.filesWithoutDeclaredTests.size > 0) {
|
|
686
|
-
for (const testFile of this.filesWithoutDeclaredTests) {
|
|
687
|
-
if (!this.filesWithMissingAvaImports.has(testFile)) {
|
|
688
|
-
this.lineWriter.writeLine(colors.error(`${figures.cross} No tests found in ${this.relativeFile(testFile)}`) + firstLinePostfix);
|
|
689
|
-
firstLinePostfix = '';
|
|
690
|
-
wroteSomething = true;
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
}
|
|
545
|
+
}
|
|
694
546
|
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
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}`));
|
|
700
556
|
}
|
|
701
557
|
}
|
|
702
558
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
this.lineWriter.writeLine(colors.error(`${figures.cross} Line numbers for ${this.relativeFile(testFile)} did not match any tests`) + firstLinePostfix);
|
|
707
|
-
firstLinePostfix = '';
|
|
708
|
-
wroteSomething = true;
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
}
|
|
559
|
+
this.lineWriter.writeLine();
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
712
562
|
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
wroteSomething = false;
|
|
718
|
-
}
|
|
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;
|
|
719
567
|
}
|
|
720
568
|
|
|
569
|
+
this.lineWriter.writeLine(colors.log(figures.line));
|
|
570
|
+
this.lineWriter.writeLine();
|
|
571
|
+
|
|
721
572
|
if (this.failures.length > 0) {
|
|
722
573
|
const writeTrailingLines = this.internalErrors.length > 0 || this.sharedWorkerErrors.length > 0 || this.uncaughtExceptions.length > 0 || this.unhandledRejections.length > 0;
|
|
723
574
|
|
|
@@ -727,97 +578,14 @@ class Reporter {
|
|
|
727
578
|
if (event !== lastFailure) {
|
|
728
579
|
this.lineWriter.writeLine();
|
|
729
580
|
this.lineWriter.writeLine();
|
|
730
|
-
} else if (!
|
|
731
|
-
this.lineWriter.writeLine();
|
|
732
|
-
this.lineWriter.writeLine();
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
wroteSomething = true;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
if (this.verbose) {
|
|
739
|
-
this.lineWriter.writeLine(colors.log(figures.line));
|
|
740
|
-
this.lineWriter.writeLine();
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
if (!this.verbose) {
|
|
745
|
-
if (this.internalErrors.length > 0) {
|
|
746
|
-
const writeTrailingLines = this.sharedWorkerErrors.length > 0 || this.uncaughtExceptions.length > 0 || this.unhandledRejections.length > 0;
|
|
747
|
-
|
|
748
|
-
const last = this.internalErrors[this.internalErrors.length - 1];
|
|
749
|
-
for (const event of this.internalErrors) {
|
|
750
|
-
if (event.testFile) {
|
|
751
|
-
this.lineWriter.writeLine(colors.error(`${figures.cross} Internal error when running ${this.relativeFile(event.testFile)}`));
|
|
752
|
-
} else {
|
|
753
|
-
this.lineWriter.writeLine(colors.error(`${figures.cross} Internal error`));
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
this.lineWriter.writeLine(colors.stack(event.err.summary));
|
|
757
|
-
this.lineWriter.writeLine(colors.errorStack(event.err.stack));
|
|
758
|
-
if (event !== last || writeTrailingLines) {
|
|
759
|
-
this.lineWriter.writeLine();
|
|
760
|
-
this.lineWriter.writeLine();
|
|
761
|
-
this.lineWriter.writeLine();
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
wroteSomething = true;
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
if (this.sharedWorkerErrors.length > 0) {
|
|
769
|
-
const writeTrailingLines = this.uncaughtExceptions.length > 0 || this.unhandledRejections.length > 0;
|
|
770
|
-
|
|
771
|
-
const last = this.sharedWorkerErrors[this.sharedWorkerErrors.length - 1];
|
|
772
|
-
for (const evt of this.sharedWorkerErrors) {
|
|
773
|
-
this.lineWriter.writeLine(colors.error(`${figures.cross} Error in shared worker`));
|
|
774
|
-
this.lineWriter.writeLine();
|
|
775
|
-
this.writeErr(evt.err);
|
|
776
|
-
if (evt !== last || writeTrailingLines) {
|
|
777
|
-
this.lineWriter.writeLine();
|
|
778
|
-
this.lineWriter.writeLine();
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
wroteSomething = true;
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
if (this.uncaughtExceptions.length > 0) {
|
|
786
|
-
const writeTrailingLines = this.unhandledRejections.length > 0;
|
|
787
|
-
|
|
788
|
-
const last = this.uncaughtExceptions[this.uncaughtExceptions.length - 1];
|
|
789
|
-
for (const event of this.uncaughtExceptions) {
|
|
790
|
-
this.lineWriter.writeLine(colors.title(`Uncaught exception in ${this.relativeFile(event.testFile)}`));
|
|
581
|
+
} else if (!true && writeTrailingLines) {
|
|
791
582
|
this.lineWriter.writeLine();
|
|
792
|
-
this.writeErr(event);
|
|
793
|
-
if (event !== last || writeTrailingLines) {
|
|
794
|
-
this.lineWriter.writeLine();
|
|
795
|
-
this.lineWriter.writeLine();
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
wroteSomething = true;
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
if (this.unhandledRejections.length > 0) {
|
|
803
|
-
const last = this.unhandledRejections[this.unhandledRejections.length - 1];
|
|
804
|
-
for (const event of this.unhandledRejections) {
|
|
805
|
-
this.lineWriter.writeLine(colors.title(`Unhandled rejection in ${this.relativeFile(event.testFile)}`));
|
|
806
583
|
this.lineWriter.writeLine();
|
|
807
|
-
this.writeErr(event);
|
|
808
|
-
if (event !== last) {
|
|
809
|
-
this.lineWriter.writeLine();
|
|
810
|
-
this.lineWriter.writeLine();
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
wroteSomething = true;
|
|
814
584
|
}
|
|
815
585
|
}
|
|
816
586
|
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
this.lineWriter.writeLine();
|
|
820
|
-
}
|
|
587
|
+
this.lineWriter.writeLine(colors.log(figures.line));
|
|
588
|
+
this.lineWriter.writeLine();
|
|
821
589
|
}
|
|
822
590
|
|
|
823
591
|
if (this.failFastEnabled && (this.stats.remainingTests > 0 || this.stats.files > this.stats.finishedWorkers)) {
|
|
@@ -838,16 +606,14 @@ class Reporter {
|
|
|
838
606
|
}
|
|
839
607
|
|
|
840
608
|
this.lineWriter.writeLine(colors.information(`\`--fail-fast\` is on. ${remaining}.`));
|
|
841
|
-
|
|
842
|
-
this.lineWriter.writeLine();
|
|
843
|
-
}
|
|
609
|
+
this.lineWriter.writeLine();
|
|
844
610
|
}
|
|
845
611
|
|
|
846
|
-
if (this.
|
|
612
|
+
if (this.stats.parallelRuns) {
|
|
847
613
|
const {
|
|
848
614
|
currentFileCount,
|
|
849
615
|
currentIndex,
|
|
850
|
-
totalRuns
|
|
616
|
+
totalRuns,
|
|
851
617
|
} = this.stats.parallelRuns;
|
|
852
618
|
this.lineWriter.writeLine(colors.information(`Ran ${currentFileCount} test ${plur('file', currentFileCount)} out of ${this.stats.files} for job ${currentIndex + 1} of ${totalRuns}`));
|
|
853
619
|
this.lineWriter.writeLine();
|
|
@@ -864,11 +630,11 @@ class Reporter {
|
|
|
864
630
|
}
|
|
865
631
|
|
|
866
632
|
if (
|
|
867
|
-
this.stats.failedHooks === 0
|
|
868
|
-
this.stats.failedTests === 0
|
|
869
|
-
this.stats.passedTests > 0
|
|
633
|
+
this.stats.failedHooks === 0
|
|
634
|
+
&& this.stats.failedTests === 0
|
|
635
|
+
&& this.stats.passedTests > 0
|
|
870
636
|
) {
|
|
871
|
-
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,
|
|
872
638
|
);
|
|
873
639
|
firstLinePostfix = '';
|
|
874
640
|
}
|
|
@@ -902,4 +668,3 @@ class Reporter {
|
|
|
902
668
|
}
|
|
903
669
|
}
|
|
904
670
|
}
|
|
905
|
-
module.exports = Reporter;
|