ava 3.9.0 → 3.11.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/index.d.ts +2 -2
- package/lib/api.js +1 -1
- package/lib/assert.js +31 -21
- package/lib/cli.js +28 -4
- package/lib/load-config.js +1 -1
- package/lib/reporters/default.js +65 -10
- package/lib/reporters/tap.js +3 -0
- package/lib/runner.js +12 -3
- package/lib/test.js +19 -5
- package/lib/worker/subprocess.js +12 -4
- package/package.json +19 -19
- package/lib/reporters/while-corked.js +0 -13
package/index.d.ts
CHANGED
|
@@ -130,7 +130,7 @@ export interface DeepEqualAssertion {
|
|
|
130
130
|
|
|
131
131
|
export interface LikeAssertion {
|
|
132
132
|
/** Assert that `value` is like `selector`. */
|
|
133
|
-
(value: any, selector: Record<string,
|
|
133
|
+
(value: any, selector: Record<string, any>, message?: string): void;
|
|
134
134
|
|
|
135
135
|
/** Skip this assertion. */
|
|
136
136
|
skip(value: any, selector: any, message?: string): void;
|
|
@@ -353,7 +353,7 @@ export interface TimeoutFn {
|
|
|
353
353
|
* Set a timeout for the test, in milliseconds. The test will fail if the timeout is exceeded.
|
|
354
354
|
* The timeout is reset each time an assertion is made.
|
|
355
355
|
*/
|
|
356
|
-
(ms: number): void;
|
|
356
|
+
(ms: number, message?: string): void;
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
export interface TeardownFn {
|
package/lib/api.js
CHANGED
|
@@ -147,7 +147,7 @@ class Api extends Emittery {
|
|
|
147
147
|
runStatus = new RunStatus(selectedFiles.length, null);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
const debugWithoutSpecificFile = Boolean(this.options.debug) && selectedFiles.length !== 1;
|
|
150
|
+
const debugWithoutSpecificFile = Boolean(this.options.debug) && !this.options.debug.active && selectedFiles.length !== 1;
|
|
151
151
|
|
|
152
152
|
await this.emit('run', {
|
|
153
153
|
bailWithoutReporting: debugWithoutSpecificFile,
|
package/lib/assert.js
CHANGED
|
@@ -64,6 +64,21 @@ class AssertionError extends Error {
|
|
|
64
64
|
}
|
|
65
65
|
exports.AssertionError = AssertionError;
|
|
66
66
|
|
|
67
|
+
function checkAssertionMessage(assertion, message) {
|
|
68
|
+
if (typeof message === 'undefined' || typeof message === 'string') {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return new AssertionError({
|
|
73
|
+
assertion,
|
|
74
|
+
improperUsage: true,
|
|
75
|
+
message: 'The assertion message must be a string',
|
|
76
|
+
values: [formatWithLabel('Called with:', message)]
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
exports.checkAssertionMessage = checkAssertionMessage;
|
|
81
|
+
|
|
67
82
|
function getErrorWithLongStackTrace() {
|
|
68
83
|
const limitBefore = Error.stackTraceLimit;
|
|
69
84
|
Error.stackTraceLimit = Infinity;
|
|
@@ -243,7 +258,8 @@ class Assertions {
|
|
|
243
258
|
skip = notImplemented,
|
|
244
259
|
compareWithSnapshot = notImplemented,
|
|
245
260
|
powerAssert,
|
|
246
|
-
experiments = {}
|
|
261
|
+
experiments = {},
|
|
262
|
+
disableSnapshots = false
|
|
247
263
|
} = {}) {
|
|
248
264
|
const withSkip = assertionFn => {
|
|
249
265
|
assertionFn.skip = skip;
|
|
@@ -268,22 +284,16 @@ class Assertions {
|
|
|
268
284
|
});
|
|
269
285
|
|
|
270
286
|
const checkMessage = (assertion, message, powerAssert = false) => {
|
|
271
|
-
|
|
272
|
-
|
|
287
|
+
const result = checkAssertionMessage(assertion, message);
|
|
288
|
+
if (result === true) {
|
|
289
|
+
return this.true;
|
|
273
290
|
}
|
|
274
291
|
|
|
275
|
-
const error = new AssertionError({
|
|
276
|
-
assertion,
|
|
277
|
-
improperUsage: true,
|
|
278
|
-
message: 'The assertion message must be a string',
|
|
279
|
-
values: [formatWithLabel('Called with:', message)]
|
|
280
|
-
});
|
|
281
|
-
|
|
282
292
|
if (powerAssert) {
|
|
283
|
-
throw
|
|
293
|
+
throw result;
|
|
284
294
|
}
|
|
285
295
|
|
|
286
|
-
fail(
|
|
296
|
+
fail(result);
|
|
287
297
|
return false;
|
|
288
298
|
};
|
|
289
299
|
|
|
@@ -389,15 +399,6 @@ class Assertions {
|
|
|
389
399
|
});
|
|
390
400
|
|
|
391
401
|
this.like = withSkip((actual, selector, message) => {
|
|
392
|
-
if (!experiments.likeAssertion) {
|
|
393
|
-
fail(new AssertionError({
|
|
394
|
-
assertion: 'like',
|
|
395
|
-
improperUsage: true,
|
|
396
|
-
message: 'You must enable the `likeAssertion` experiment in order to use `t.like()`'
|
|
397
|
-
}));
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
402
|
if (!checkMessage('like', message)) {
|
|
402
403
|
return;
|
|
403
404
|
}
|
|
@@ -690,6 +691,15 @@ class Assertions {
|
|
|
690
691
|
});
|
|
691
692
|
|
|
692
693
|
this.snapshot = withSkip((expected, ...rest) => {
|
|
694
|
+
if (disableSnapshots && experiments.disableSnapshotsInHooks) {
|
|
695
|
+
fail(new AssertionError({
|
|
696
|
+
assertion: 'snapshot',
|
|
697
|
+
message: '`t.snapshot()` can only be used in tests',
|
|
698
|
+
improperUsage: true
|
|
699
|
+
}));
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
|
|
693
703
|
let message;
|
|
694
704
|
let snapshotOptions;
|
|
695
705
|
if (rest.length > 1) {
|
package/lib/cli.js
CHANGED
|
@@ -88,7 +88,19 @@ exports.run = async () => { // eslint-disable-line complexity
|
|
|
88
88
|
confError = error;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
// Enter debug mode if the main process is being inspected. This assumes the
|
|
92
|
+
// worker processes are automatically inspected, too. It is not necessary to
|
|
93
|
+
// run AVA with the debug command, though it's allowed.
|
|
94
|
+
const activeInspector = require('inspector').url() !== undefined; // eslint-disable-line node/no-unsupported-features/node-builtins
|
|
95
|
+
let debug = activeInspector ?
|
|
96
|
+
{
|
|
97
|
+
active: true,
|
|
98
|
+
break: false,
|
|
99
|
+
files: [],
|
|
100
|
+
host: undefined,
|
|
101
|
+
port: undefined
|
|
102
|
+
} : null;
|
|
103
|
+
|
|
92
104
|
let resetCache = false;
|
|
93
105
|
const {argv} = yargs
|
|
94
106
|
.parserConfiguration({
|
|
@@ -122,7 +134,11 @@ exports.run = async () => { // eslint-disable-line complexity
|
|
|
122
134
|
array: true,
|
|
123
135
|
describe: 'Glob patterns to select what test files to run. Leave empty if you want AVA to run all test files instead. Add a colon and specify line numbers of specific tests to run',
|
|
124
136
|
type: 'string'
|
|
125
|
-
})
|
|
137
|
+
}), argv => {
|
|
138
|
+
if (activeInspector) {
|
|
139
|
+
debug.files = argv.pattern || [];
|
|
140
|
+
}
|
|
141
|
+
})
|
|
126
142
|
.command(
|
|
127
143
|
'debug [<pattern>...]',
|
|
128
144
|
'Activate Node.js inspector and run a single test file',
|
|
@@ -148,6 +164,7 @@ exports.run = async () => { // eslint-disable-line complexity
|
|
|
148
164
|
}),
|
|
149
165
|
argv => {
|
|
150
166
|
debug = {
|
|
167
|
+
active: activeInspector,
|
|
151
168
|
break: argv.break === true,
|
|
152
169
|
files: argv.pattern,
|
|
153
170
|
host: argv.host,
|
|
@@ -182,6 +199,10 @@ exports.run = async () => { // eslint-disable-line complexity
|
|
|
182
199
|
const chalkOptions = {level: combined.color === false ? 0 : require('chalk').level};
|
|
183
200
|
const chalk = require('./chalk').set(chalkOptions);
|
|
184
201
|
|
|
202
|
+
if (combined.updateSnapshots && combined.match) {
|
|
203
|
+
exit('Snapshots cannot be updated when matching specific tests.');
|
|
204
|
+
}
|
|
205
|
+
|
|
185
206
|
if (confError) {
|
|
186
207
|
if (confError.parent) {
|
|
187
208
|
exit(`${confError.message}\n\n${chalk.gray((confError.parent && confError.parent.stack) || confError.parent)}`);
|
|
@@ -356,6 +377,9 @@ exports.run = async () => { // eslint-disable-line complexity
|
|
|
356
377
|
pattern: normalizePattern(path.relative(projectDir, path.resolve(process.cwd(), pattern))),
|
|
357
378
|
...rest
|
|
358
379
|
}));
|
|
380
|
+
if (combined.updateSnapshots && filter.some(condition => condition.lineNumbers !== null)) {
|
|
381
|
+
exit('Snapshots cannot be updated when selecting specific tests by their line number.');
|
|
382
|
+
}
|
|
359
383
|
|
|
360
384
|
const api = new Api({
|
|
361
385
|
cacheEnabled: combined.cache !== false,
|
|
@@ -437,14 +461,14 @@ exports.run = async () => { // eslint-disable-line complexity
|
|
|
437
461
|
} else {
|
|
438
462
|
let debugWithoutSpecificFile = false;
|
|
439
463
|
api.on('run', plan => {
|
|
440
|
-
if (
|
|
464
|
+
if (debug !== null && plan.files.length !== 1) {
|
|
441
465
|
debugWithoutSpecificFile = true;
|
|
442
466
|
}
|
|
443
467
|
});
|
|
444
468
|
|
|
445
469
|
const runStatus = await api.run({filter});
|
|
446
470
|
|
|
447
|
-
if (debugWithoutSpecificFile) {
|
|
471
|
+
if (debugWithoutSpecificFile && !debug.active) {
|
|
448
472
|
exit('Provide the path to the test file you wish to debug');
|
|
449
473
|
return;
|
|
450
474
|
}
|
package/lib/load-config.js
CHANGED
|
@@ -7,7 +7,7 @@ const pkgConf = require('pkg-conf');
|
|
|
7
7
|
|
|
8
8
|
const NO_SUCH_FILE = Symbol('no ava.config.js file');
|
|
9
9
|
const MISSING_DEFAULT_EXPORT = Symbol('missing default export');
|
|
10
|
-
const EXPERIMENTS = new Set(['
|
|
10
|
+
const EXPERIMENTS = new Set(['disableSnapshotsInHooks', 'reverseTeardowns']);
|
|
11
11
|
|
|
12
12
|
// *Very* rudimentary support for loading ava.config.js files containing an `export default` statement.
|
|
13
13
|
const evaluateJsConfig = configFile => {
|
package/lib/reporters/default.js
CHANGED
|
@@ -18,7 +18,6 @@ const colors = require('./colors');
|
|
|
18
18
|
const formatSerializedError = require('./format-serialized-error');
|
|
19
19
|
const improperUsageMessages = require('./improper-usage-messages');
|
|
20
20
|
const prefixTitle = require('./prefix-title');
|
|
21
|
-
const whileCorked = require('./while-corked');
|
|
22
21
|
|
|
23
22
|
const nodeInternals = require('stack-utils').nodeInternals();
|
|
24
23
|
|
|
@@ -97,6 +96,48 @@ class LineWriterWithSpinner extends LineWriter {
|
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
|
|
99
|
+
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
|
+
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
|
+
decorateWriter(fn) {
|
|
129
|
+
return function (...args) {
|
|
130
|
+
cork();
|
|
131
|
+
try {
|
|
132
|
+
return fn.apply(this, args);
|
|
133
|
+
} finally {
|
|
134
|
+
uncork();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
100
141
|
class Reporter {
|
|
101
142
|
constructor({
|
|
102
143
|
verbose,
|
|
@@ -112,13 +153,16 @@ class Reporter {
|
|
|
112
153
|
this.stdStream = stdStream;
|
|
113
154
|
this.watching = watching;
|
|
114
155
|
this.relativeFile = file => path.relative(projectDir, file);
|
|
115
|
-
|
|
156
|
+
|
|
157
|
+
const {decorateWriter, decorateFlushingWriter} = manageCorking(this.reportStream);
|
|
158
|
+
this.consumeStateChange = decorateWriter(this.consumeStateChange);
|
|
159
|
+
this.endRun = decorateWriter(this.endRun);
|
|
116
160
|
|
|
117
161
|
if (this.verbose) {
|
|
118
162
|
this.durationThreshold = durationThreshold || 100;
|
|
119
163
|
this.spinner = null;
|
|
164
|
+
this.clearSpinner = () => {};
|
|
120
165
|
this.lineWriter = new LineWriter(this.reportStream);
|
|
121
|
-
this.endRun = whileCorked(this.reportStream, this.endRun);
|
|
122
166
|
} else {
|
|
123
167
|
this.spinner = ora({
|
|
124
168
|
isEnabled: true,
|
|
@@ -128,8 +172,8 @@ class Reporter {
|
|
|
128
172
|
spinner: spinner || (process.platform === 'win32' ? 'line' : 'dots'),
|
|
129
173
|
stream: reportStream
|
|
130
174
|
});
|
|
175
|
+
this.clearSpinner = decorateFlushingWriter(this.spinner.clear.bind(this.spinner));
|
|
131
176
|
this.lineWriter = new LineWriterWithSpinner(this.reportStream, this.spinner);
|
|
132
|
-
this.endRun = whileCorked(this.reportStream, whileCorked(this.lineWriter, this.endRun));
|
|
133
177
|
}
|
|
134
178
|
|
|
135
179
|
this.reset();
|
|
@@ -153,6 +197,7 @@ class Reporter {
|
|
|
153
197
|
this.lineNumberErrors = [];
|
|
154
198
|
this.uncaughtExceptions = [];
|
|
155
199
|
this.unhandledRejections = [];
|
|
200
|
+
this.unsavedSnapshots = [];
|
|
156
201
|
|
|
157
202
|
this.previousFailures = 0;
|
|
158
203
|
|
|
@@ -295,6 +340,10 @@ class Reporter {
|
|
|
295
340
|
break;
|
|
296
341
|
}
|
|
297
342
|
|
|
343
|
+
case 'snapshot-error':
|
|
344
|
+
this.unsavedSnapshots.push(event);
|
|
345
|
+
break;
|
|
346
|
+
|
|
298
347
|
case 'uncaught-exception': {
|
|
299
348
|
this.uncaughtExceptions.push(event);
|
|
300
349
|
|
|
@@ -357,9 +406,7 @@ class Reporter {
|
|
|
357
406
|
|
|
358
407
|
case 'worker-stderr': {
|
|
359
408
|
// Forcibly clear the spinner, writing the chunk corrupts the TTY.
|
|
360
|
-
|
|
361
|
-
this.spinner.clear();
|
|
362
|
-
}
|
|
409
|
+
this.clearSpinner();
|
|
363
410
|
|
|
364
411
|
this.stdStream.write(event.chunk);
|
|
365
412
|
// If the chunk does not end with a linebreak, *forcibly* write one to
|
|
@@ -381,9 +428,7 @@ class Reporter {
|
|
|
381
428
|
|
|
382
429
|
case 'worker-stdout': {
|
|
383
430
|
// Forcibly clear the spinner, writing the chunk corrupts the TTY.
|
|
384
|
-
|
|
385
|
-
this.spinner.clear();
|
|
386
|
-
}
|
|
431
|
+
this.clearSpinner();
|
|
387
432
|
|
|
388
433
|
this.stdStream.write(event.chunk);
|
|
389
434
|
// If the chunk does not end with a linebreak, *forcibly* write one to
|
|
@@ -749,6 +794,16 @@ class Reporter {
|
|
|
749
794
|
}
|
|
750
795
|
}
|
|
751
796
|
|
|
797
|
+
if (this.unsavedSnapshots.length > 0) {
|
|
798
|
+
this.lineWriter.writeLine(colors.title('Could not update snapshots for the following test files:'));
|
|
799
|
+
this.lineWriter.writeLine();
|
|
800
|
+
for (const event of this.unsavedSnapshots) {
|
|
801
|
+
this.lineWriter.writeLine(`${figures.warning} ${this.relativeFile(event.testFile)}`);
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
this.lineWriter.writeLine();
|
|
805
|
+
}
|
|
806
|
+
|
|
752
807
|
if (this.failFastEnabled && (this.stats.remainingTests > 0 || this.stats.files > this.stats.finishedWorkers)) {
|
|
753
808
|
let remaining = '';
|
|
754
809
|
if (this.stats.remainingTests > 0) {
|
package/lib/reporters/tap.js
CHANGED
|
@@ -158,6 +158,9 @@ class TapReporter {
|
|
|
158
158
|
this.writeTest(evt, {passed: false, todo: true, skip: false});
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
break;
|
|
162
|
+
case 'snapshot-error':
|
|
163
|
+
this.writeComment(evt, {title: 'Could not update snapshots'});
|
|
161
164
|
break;
|
|
162
165
|
case 'stats':
|
|
163
166
|
this.stats = evt.stats;
|
package/lib/runner.js
CHANGED
|
@@ -23,6 +23,7 @@ class Runner extends Emittery {
|
|
|
23
23
|
this.recordNewSnapshots = options.recordNewSnapshots === true;
|
|
24
24
|
this.runOnlyExclusive = options.runOnlyExclusive === true;
|
|
25
25
|
this.serial = options.serial === true;
|
|
26
|
+
this.skippingTests = false;
|
|
26
27
|
this.snapshotDir = options.snapshotDir;
|
|
27
28
|
this.updateSnapshots = options.updateSnapshots;
|
|
28
29
|
|
|
@@ -147,6 +148,10 @@ class Runner extends Emittery {
|
|
|
147
148
|
task.metadata.exclusive = matcher([title], this.match).length === 1;
|
|
148
149
|
}
|
|
149
150
|
|
|
151
|
+
if (task.metadata.skipped) {
|
|
152
|
+
this.skippingTests = true;
|
|
153
|
+
}
|
|
154
|
+
|
|
150
155
|
if (task.metadata.exclusive) {
|
|
151
156
|
this.runOnlyExclusive = true;
|
|
152
157
|
}
|
|
@@ -182,7 +187,7 @@ class Runner extends Emittery {
|
|
|
182
187
|
fixedLocation: this.snapshotDir,
|
|
183
188
|
projectDir: this.projectDir,
|
|
184
189
|
recordNewSnapshots: this.recordNewSnapshots,
|
|
185
|
-
updating: this.updateSnapshots
|
|
190
|
+
updating: this.updateSnapshots && !this.runOnlyExclusive && !this.skippingTests
|
|
186
191
|
});
|
|
187
192
|
this.emit('dependency', this.snapshots.snapPath);
|
|
188
193
|
}
|
|
@@ -191,8 +196,12 @@ class Runner extends Emittery {
|
|
|
191
196
|
}
|
|
192
197
|
|
|
193
198
|
saveSnapshotState() {
|
|
199
|
+
if (this.updateSnapshots && (this.runOnlyExclusive || this.skippingTests)) {
|
|
200
|
+
return {cannotSave: true};
|
|
201
|
+
}
|
|
202
|
+
|
|
194
203
|
if (this.snapshots) {
|
|
195
|
-
return this.snapshots.save();
|
|
204
|
+
return {touchedFiles: this.snapshots.save()};
|
|
196
205
|
}
|
|
197
206
|
|
|
198
207
|
if (this.updateSnapshots) {
|
|
@@ -201,7 +210,7 @@ class Runner extends Emittery {
|
|
|
201
210
|
// were skipped. Perhaps emit a warning if this occurs?
|
|
202
211
|
}
|
|
203
212
|
|
|
204
|
-
return
|
|
213
|
+
return {};
|
|
205
214
|
}
|
|
206
215
|
|
|
207
216
|
onRun(runnable) {
|
package/lib/test.js
CHANGED
|
@@ -40,7 +40,8 @@ class ExecutionContext extends assert.Assertions {
|
|
|
40
40
|
return test.compareWithSnapshot(options);
|
|
41
41
|
},
|
|
42
42
|
powerAssert: test.powerAssert,
|
|
43
|
-
experiments: test.experiments
|
|
43
|
+
experiments: test.experiments,
|
|
44
|
+
disableSnapshots: test.isHook === true
|
|
44
45
|
});
|
|
45
46
|
testMap.set(this, test);
|
|
46
47
|
|
|
@@ -65,8 +66,8 @@ class ExecutionContext extends assert.Assertions {
|
|
|
65
66
|
|
|
66
67
|
this.plan.skip = () => {};
|
|
67
68
|
|
|
68
|
-
this.timeout = ms => {
|
|
69
|
-
test.timeout(ms);
|
|
69
|
+
this.timeout = (ms, message) => {
|
|
70
|
+
test.timeout(ms, message);
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
this.teardown = callback => {
|
|
@@ -74,6 +75,12 @@ class ExecutionContext extends assert.Assertions {
|
|
|
74
75
|
};
|
|
75
76
|
|
|
76
77
|
this.try = async (...attemptArgs) => {
|
|
78
|
+
if (test.isHook) {
|
|
79
|
+
const error = new Error('`t.try()` can only be used in tests');
|
|
80
|
+
test.saveFirstError(error);
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
|
|
77
84
|
const {args, buildTitle, implementations, receivedImplementationArray} = parseTestArgs(attemptArgs);
|
|
78
85
|
|
|
79
86
|
if (implementations.length === 0) {
|
|
@@ -431,7 +438,14 @@ class Test {
|
|
|
431
438
|
this.planError = planError;
|
|
432
439
|
}
|
|
433
440
|
|
|
434
|
-
timeout(ms) {
|
|
441
|
+
timeout(ms, message) {
|
|
442
|
+
const result = assert.checkAssertionMessage('timeout', message);
|
|
443
|
+
if (result !== true) {
|
|
444
|
+
this.saveFirstError(result);
|
|
445
|
+
// Allow the timeout to be set even when the message is invalid.
|
|
446
|
+
message = '';
|
|
447
|
+
}
|
|
448
|
+
|
|
435
449
|
if (this.finishing) {
|
|
436
450
|
return;
|
|
437
451
|
}
|
|
@@ -439,7 +453,7 @@ class Test {
|
|
|
439
453
|
this.clearTimeout();
|
|
440
454
|
this.timeoutMs = ms;
|
|
441
455
|
this.timeoutTimer = nowAndTimers.setTimeout(() => {
|
|
442
|
-
this.saveFirstError(new Error('Test timeout exceeded'));
|
|
456
|
+
this.saveFirstError(new Error(message || 'Test timeout exceeded'));
|
|
443
457
|
|
|
444
458
|
if (this.finishDueToTimeout) {
|
|
445
459
|
this.finishDueToTimeout();
|
package/lib/worker/subprocess.js
CHANGED
|
@@ -91,8 +91,10 @@ ipc.options.then(async options => {
|
|
|
91
91
|
|
|
92
92
|
runner.on('finish', () => {
|
|
93
93
|
try {
|
|
94
|
-
const touchedFiles = runner.saveSnapshotState();
|
|
95
|
-
if (
|
|
94
|
+
const {cannotSave, touchedFiles} = runner.saveSnapshotState();
|
|
95
|
+
if (cannotSave) {
|
|
96
|
+
ipc.send({type: 'snapshot-error'});
|
|
97
|
+
} else if (touchedFiles) {
|
|
96
98
|
ipc.send({type: 'touched-files', files: touchedFiles});
|
|
97
99
|
}
|
|
98
100
|
} catch (error) {
|
|
@@ -203,8 +205,14 @@ ipc.options.then(async options => {
|
|
|
203
205
|
// to make sure we also track dependencies with custom require hooks
|
|
204
206
|
dependencyTracking.install(testPath);
|
|
205
207
|
|
|
206
|
-
if (options.debug) {
|
|
207
|
-
|
|
208
|
+
if (options.debug && options.debug.port !== undefined && options.debug.host !== undefined) {
|
|
209
|
+
// If an inspector was active when the main process started, and is
|
|
210
|
+
// already active for the worker process, do not open a new one.
|
|
211
|
+
const inspector = require('inspector'); // eslint-disable-line node/no-unsupported-features/node-builtins
|
|
212
|
+
if (!options.debug.active || inspector.url() === undefined) {
|
|
213
|
+
inspector.open(options.debug.port, options.debug.host, true);
|
|
214
|
+
}
|
|
215
|
+
|
|
208
216
|
if (options.debug.break) {
|
|
209
217
|
debugger; // eslint-disable-line no-debugger
|
|
210
218
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ava",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.1",
|
|
4
4
|
"description": "Node.js test runner that lets you develop with confidence.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "avajs/ava",
|
|
@@ -57,27 +57,27 @@
|
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@concordance/react": "^2.0.0",
|
|
59
59
|
"acorn": "^7.3.1",
|
|
60
|
-
"acorn-walk": "^7.
|
|
60
|
+
"acorn-walk": "^7.2.0",
|
|
61
61
|
"ansi-styles": "^4.2.1",
|
|
62
62
|
"arrgv": "^1.0.2",
|
|
63
63
|
"arrify": "^2.0.1",
|
|
64
64
|
"callsites": "^3.1.0",
|
|
65
65
|
"chalk": "^4.1.0",
|
|
66
|
-
"chokidar": "^3.4.
|
|
66
|
+
"chokidar": "^3.4.1",
|
|
67
67
|
"chunkd": "^2.0.1",
|
|
68
68
|
"ci-info": "^2.0.0",
|
|
69
|
-
"ci-parallel-vars": "^1.0.
|
|
69
|
+
"ci-parallel-vars": "^1.0.1",
|
|
70
70
|
"clean-yaml-object": "^0.1.0",
|
|
71
71
|
"cli-cursor": "^3.1.0",
|
|
72
72
|
"cli-truncate": "^2.1.0",
|
|
73
|
-
"code-excerpt": "^
|
|
73
|
+
"code-excerpt": "^3.0.0",
|
|
74
74
|
"common-path-prefix": "^3.0.0",
|
|
75
75
|
"concordance": "^5.0.0",
|
|
76
76
|
"convert-source-map": "^1.7.0",
|
|
77
77
|
"currently-unhandled": "^0.4.1",
|
|
78
78
|
"debug": "^4.1.1",
|
|
79
79
|
"del": "^5.1.0",
|
|
80
|
-
"emittery": "^0.7.
|
|
80
|
+
"emittery": "^0.7.1",
|
|
81
81
|
"equal-length": "^1.0.0",
|
|
82
82
|
"figures": "^3.2.0",
|
|
83
83
|
"globby": "^11.0.1",
|
|
@@ -85,14 +85,14 @@
|
|
|
85
85
|
"import-local": "^3.0.2",
|
|
86
86
|
"indent-string": "^4.0.0",
|
|
87
87
|
"is-error": "^2.2.2",
|
|
88
|
-
"is-plain-object": "^
|
|
88
|
+
"is-plain-object": "^4.1.1",
|
|
89
89
|
"is-promise": "^4.0.0",
|
|
90
|
-
"lodash": "^4.17.
|
|
90
|
+
"lodash": "^4.17.19",
|
|
91
91
|
"matcher": "^3.0.0",
|
|
92
92
|
"md5-hex": "^3.0.1",
|
|
93
93
|
"mem": "^6.1.0",
|
|
94
94
|
"ms": "^2.1.2",
|
|
95
|
-
"ora": "^4.0.
|
|
95
|
+
"ora": "^4.0.5",
|
|
96
96
|
"p-map": "^4.0.0",
|
|
97
97
|
"picomatch": "^2.2.2",
|
|
98
98
|
"pkg-conf": "^3.1.0",
|
|
@@ -109,18 +109,18 @@
|
|
|
109
109
|
"trim-off-newlines": "^1.0.1",
|
|
110
110
|
"update-notifier": "^4.1.0",
|
|
111
111
|
"write-file-atomic": "^3.0.3",
|
|
112
|
-
"yargs": "^15.
|
|
112
|
+
"yargs": "^15.4.1"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
115
|
"@ava/babel": "^1.0.1",
|
|
116
116
|
"@ava/test": "github:avajs/test",
|
|
117
|
-
"@babel/plugin-proposal-do-expressions": "^7.10.
|
|
117
|
+
"@babel/plugin-proposal-do-expressions": "^7.10.4",
|
|
118
118
|
"@sinonjs/fake-timers": "^6.0.1",
|
|
119
119
|
"ansi-escapes": "^4.3.1",
|
|
120
|
-
"c8": "^7.2.
|
|
121
|
-
"delay": "^4.
|
|
120
|
+
"c8": "^7.2.1",
|
|
121
|
+
"delay": "^4.4.0",
|
|
122
122
|
"esm": "^3.2.25",
|
|
123
|
-
"execa": "^4.0.
|
|
123
|
+
"execa": "^4.0.3",
|
|
124
124
|
"get-stream": "^5.1.0",
|
|
125
125
|
"p-event": "^4.2.0",
|
|
126
126
|
"proxyquire": "^2.1.3",
|
|
@@ -129,13 +129,13 @@
|
|
|
129
129
|
"replace-string": "^3.1.0",
|
|
130
130
|
"sinon": "^9.0.2",
|
|
131
131
|
"source-map-fixtures": "^2.1.0",
|
|
132
|
-
"tap": "^14.10.
|
|
132
|
+
"tap": "^14.10.8",
|
|
133
133
|
"temp-write": "^4.0.0",
|
|
134
|
-
"tempy": "^0.
|
|
134
|
+
"tempy": "^0.6.0",
|
|
135
135
|
"touch": "^3.1.0",
|
|
136
|
-
"tsd": "^0.
|
|
137
|
-
"typescript": "^3.9.
|
|
138
|
-
"xo": "^0.32.
|
|
136
|
+
"tsd": "^0.13.1",
|
|
137
|
+
"typescript": "^3.9.7",
|
|
138
|
+
"xo": "^0.32.1",
|
|
139
139
|
"zen-observable": "^0.8.15"
|
|
140
140
|
}
|
|
141
141
|
}
|