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
|
@@ -1,27 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
export default function formatSerializedError(error) {
|
|
2
|
+
const printMessage = error.values.length === 0
|
|
3
|
+
? Boolean(error.message)
|
|
4
|
+
: !error.values[0].label.startsWith(error.message);
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
const printMessage = error.values.length === 0 ?
|
|
7
|
-
Boolean(error.message) :
|
|
8
|
-
!error.values[0].label.startsWith(error.message);
|
|
9
|
-
|
|
10
|
-
if (error.statements.length === 0 && error.values.length === 0) {
|
|
6
|
+
if (error.values.length === 0) {
|
|
11
7
|
return {formatted: null, printMessage};
|
|
12
8
|
}
|
|
13
9
|
|
|
14
10
|
let formatted = '';
|
|
15
11
|
for (const value of error.values) {
|
|
16
|
-
formatted += `${value.label}\n\n${
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
for (const statement of error.statements) {
|
|
20
|
-
formatted += `${statement[0]}\n${chalk.grey('=>')} ${trimOffNewlines(statement[1])}\n\n`;
|
|
12
|
+
formatted += `${value.label}\n\n${value.formatted}\n\n`;
|
|
21
13
|
}
|
|
22
14
|
|
|
23
|
-
formatted
|
|
24
|
-
return {formatted, printMessage};
|
|
15
|
+
return {formatted: formatted.trim(), printMessage};
|
|
25
16
|
}
|
|
26
|
-
|
|
27
|
-
module.exports = formatSerializedError;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const pkg = require('../../package.json');
|
|
1
|
+
import {chalk} from '../chalk.js';
|
|
2
|
+
import pkg from '../pkg.cjs';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
export default function buildMessage(error) {
|
|
6
5
|
if (!error.improperUsage) {
|
|
7
6
|
return null;
|
|
8
7
|
}
|
|
@@ -21,7 +20,7 @@ Visit the following URL for more details:
|
|
|
21
20
|
if (assertion === 'snapshot') {
|
|
22
21
|
const {name, snapPath} = error.improperUsage;
|
|
23
22
|
|
|
24
|
-
if (name === 'ChecksumError') {
|
|
23
|
+
if (name === 'ChecksumError' || name === 'InvalidSnapshotError') {
|
|
25
24
|
return `The snapshot file is corrupted.
|
|
26
25
|
|
|
27
26
|
File path: ${chalk.yellow(snapPath)}
|
|
@@ -39,9 +38,9 @@ Please run AVA again with the ${chalk.cyan('--update-snapshots')} flag to upgrad
|
|
|
39
38
|
|
|
40
39
|
if (name === 'VersionMismatchError') {
|
|
41
40
|
const {snapVersion, expectedVersion} = error.improperUsage;
|
|
42
|
-
const upgradeMessage = snapVersion < expectedVersion
|
|
43
|
-
`Please run AVA again with the ${chalk.cyan('--update-snapshots')} flag to upgrade.`
|
|
44
|
-
'You should upgrade AVA.';
|
|
41
|
+
const upgradeMessage = snapVersion < expectedVersion
|
|
42
|
+
? `Please run AVA again with the ${chalk.cyan('--update-snapshots')} flag to upgrade.`
|
|
43
|
+
: 'You should upgrade AVA.';
|
|
45
44
|
|
|
46
45
|
return `The snapshot file is v${snapVersion}, but only v${expectedVersion} is supported.
|
|
47
46
|
|
|
@@ -52,4 +51,4 @@ ${upgradeMessage}`;
|
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
return null;
|
|
55
|
-
}
|
|
54
|
+
}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const figures = require('figures');
|
|
4
|
-
const chalk = require('../chalk').get();
|
|
1
|
+
import path from 'node:path';
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
import figures from 'figures';
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import {chalk} from '../chalk.js';
|
|
6
|
+
|
|
7
|
+
const SEPARATOR = ' ' + chalk.gray.dim(figures.pointerSmall) + ' ';
|
|
8
|
+
|
|
9
|
+
export default function prefixTitle(extensions, base, file, title) {
|
|
10
|
+
const parts = file
|
|
10
11
|
// Only replace base if it is found at the start of the path
|
|
11
12
|
.replace(base, (match, offset) => offset === 0 ? '' : match)
|
|
12
|
-
.replace(/\.spec/, '')
|
|
13
|
-
.replace(/\.test/, '')
|
|
14
|
-
.replace(/test-/g, '')
|
|
15
|
-
.replace(/\.js$/, '')
|
|
16
13
|
.split(path.sep)
|
|
17
|
-
.filter(p => p !== '__tests__')
|
|
18
|
-
|
|
14
|
+
.filter(p => p !== '__tests__');
|
|
15
|
+
|
|
16
|
+
const filename = parts.pop()
|
|
17
|
+
.replace(/\.spec\./, '.')
|
|
18
|
+
.replace(/\.test\./, '.')
|
|
19
|
+
.replace(/test-/, '')
|
|
20
|
+
.replace(new RegExp(`.(${extensions.join('|')})$`), '');
|
|
19
21
|
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
+
return [...parts, filename, title].join(SEPARATOR);
|
|
23
|
+
}
|
package/lib/reporters/tap.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import indentString from 'indent-string';
|
|
5
|
+
import plur from 'plur';
|
|
6
|
+
import stripAnsi from 'strip-ansi';
|
|
7
|
+
import supertap from 'supertap';
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
import beautifyStack from './beautify-stack.js';
|
|
10
|
+
import prefixTitle from './prefix-title.js';
|
|
12
11
|
|
|
13
12
|
function dumpError(error) {
|
|
14
13
|
const object = {...error.object};
|
|
@@ -46,10 +45,11 @@ function dumpError(error) {
|
|
|
46
45
|
return object;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
class TapReporter {
|
|
48
|
+
export default class TapReporter {
|
|
50
49
|
constructor(options) {
|
|
51
50
|
this.i = 0;
|
|
52
51
|
|
|
52
|
+
this.extensions = options.extensions;
|
|
53
53
|
this.stdStream = options.stdStream;
|
|
54
54
|
this.reportStream = options.reportStream;
|
|
55
55
|
|
|
@@ -62,7 +62,7 @@ class TapReporter {
|
|
|
62
62
|
|
|
63
63
|
startRun(plan) {
|
|
64
64
|
if (plan.files.length > 1) {
|
|
65
|
-
this.prefixTitle = (testFile, title) => prefixTitle(plan.filePathPrefix, testFile, title);
|
|
65
|
+
this.prefixTitle = (testFile, title) => prefixTitle(this.extensions, plan.filePathPrefix, testFile, title);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
plan.status.on('stateChange', evt => this.consumeStateChange(evt));
|
|
@@ -77,7 +77,7 @@ class TapReporter {
|
|
|
77
77
|
failed: this.stats.failedTests + this.stats.remainingTests,
|
|
78
78
|
passed: this.stats.passedTests + this.stats.passedKnownFailingTests,
|
|
79
79
|
skipped: this.stats.skippedTests,
|
|
80
|
-
todo: this.stats.todoTests
|
|
80
|
+
todo: this.stats.todoTests,
|
|
81
81
|
}) + os.EOL);
|
|
82
82
|
|
|
83
83
|
if (this.stats.parallelRuns) {
|
|
@@ -90,7 +90,7 @@ class TapReporter {
|
|
|
90
90
|
failed: 0,
|
|
91
91
|
passed: 0,
|
|
92
92
|
skipped: 0,
|
|
93
|
-
todo: 0
|
|
93
|
+
todo: 0,
|
|
94
94
|
}) + os.EOL);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -102,7 +102,7 @@ class TapReporter {
|
|
|
102
102
|
index: ++this.i,
|
|
103
103
|
passed: flags.passed,
|
|
104
104
|
skip: flags.skip,
|
|
105
|
-
todo: flags.todo
|
|
105
|
+
todo: flags.todo,
|
|
106
106
|
}) + os.EOL);
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -114,7 +114,7 @@ class TapReporter {
|
|
|
114
114
|
index: ++this.i,
|
|
115
115
|
passed: false,
|
|
116
116
|
skip: false,
|
|
117
|
-
todo: false
|
|
117
|
+
todo: false,
|
|
118
118
|
}) + os.EOL);
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -213,4 +213,3 @@ class TapReporter {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
module.exports = TapReporter;
|
package/lib/run-status.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
const Emittery = require('emittery');
|
|
3
|
-
const cloneDeep = require('lodash/cloneDeep');
|
|
1
|
+
import v8 from 'node:v8';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import Emittery from 'emittery';
|
|
4
|
+
|
|
5
|
+
const copyStats = stats => v8.deserialize(v8.serialize(stats));
|
|
6
|
+
|
|
7
|
+
export default class RunStatus extends Emittery {
|
|
8
|
+
constructor(files, parallelRuns, selectionInsights) {
|
|
7
9
|
super();
|
|
8
10
|
|
|
9
11
|
this.pendingTests = new Map();
|
|
10
12
|
|
|
11
|
-
this.emptyParallelRun = parallelRuns
|
|
12
|
-
parallelRuns.currentFileCount === 0
|
|
13
|
-
parallelRuns.totalRuns > 1
|
|
14
|
-
files > 0;
|
|
13
|
+
this.emptyParallelRun = parallelRuns
|
|
14
|
+
&& parallelRuns.currentFileCount === 0
|
|
15
|
+
&& parallelRuns.totalRuns > 1
|
|
16
|
+
&& files > 0;
|
|
17
|
+
|
|
18
|
+
this.selectionInsights = selectionInsights;
|
|
15
19
|
|
|
16
20
|
this.stats = {
|
|
17
21
|
byFile: new Map(),
|
|
@@ -32,7 +36,7 @@ class RunStatus extends Emittery {
|
|
|
32
36
|
timeouts: 0,
|
|
33
37
|
todoTests: 0,
|
|
34
38
|
uncaughtExceptions: 0,
|
|
35
|
-
unhandledRejections: 0
|
|
39
|
+
unhandledRejections: 0,
|
|
36
40
|
};
|
|
37
41
|
}
|
|
38
42
|
|
|
@@ -51,7 +55,7 @@ class RunStatus extends Emittery {
|
|
|
51
55
|
todoTests: 0,
|
|
52
56
|
uncaughtExceptions: 0,
|
|
53
57
|
unhandledRejections: 0,
|
|
54
|
-
...stats
|
|
58
|
+
...stats,
|
|
55
59
|
});
|
|
56
60
|
|
|
57
61
|
this.pendingTests.set(testFile, new Set());
|
|
@@ -147,7 +151,7 @@ class RunStatus extends Emittery {
|
|
|
147
151
|
}
|
|
148
152
|
|
|
149
153
|
if (changedStats) {
|
|
150
|
-
this.emit('stateChange', {type: 'stats', stats:
|
|
154
|
+
this.emit('stateChange', {type: 'stats', stats: copyStats(stats)});
|
|
151
155
|
}
|
|
152
156
|
|
|
153
157
|
this.emit('stateChange', event);
|
|
@@ -163,15 +167,15 @@ class RunStatus extends Emittery {
|
|
|
163
167
|
}
|
|
164
168
|
|
|
165
169
|
if (
|
|
166
|
-
this.stats.declaredTests === 0
|
|
167
|
-
this.stats.internalErrors > 0
|
|
168
|
-
this.stats.failedHooks > 0
|
|
169
|
-
this.stats.failedTests > 0
|
|
170
|
-
this.stats.failedWorkers > 0
|
|
171
|
-
this.stats.sharedWorkerErrors > 0
|
|
172
|
-
this.stats.timeouts > 0
|
|
173
|
-
this.stats.uncaughtExceptions > 0
|
|
174
|
-
this.stats.unhandledRejections > 0
|
|
170
|
+
this.stats.declaredTests === 0
|
|
171
|
+
|| this.stats.internalErrors > 0
|
|
172
|
+
|| this.stats.failedHooks > 0
|
|
173
|
+
|| this.stats.failedTests > 0
|
|
174
|
+
|| this.stats.failedWorkers > 0
|
|
175
|
+
|| this.stats.sharedWorkerErrors > 0
|
|
176
|
+
|| this.stats.timeouts > 0
|
|
177
|
+
|| this.stats.uncaughtExceptions > 0
|
|
178
|
+
|| this.stats.unhandledRejections > 0
|
|
175
179
|
) {
|
|
176
180
|
return 1;
|
|
177
181
|
}
|
|
@@ -199,5 +203,3 @@ class RunStatus extends Emittery {
|
|
|
199
203
|
return [...this.stats.byFile].filter(statByFile => statByFile[1].failedTests).map(statByFile => statByFile[0]);
|
|
200
204
|
}
|
|
201
205
|
}
|
|
202
|
-
|
|
203
|
-
module.exports = RunStatus;
|