ava 3.12.0 β 3.15.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.
- package/eslint-plugin-helper.js +134 -29
- package/lib/api.js +14 -13
- package/lib/assert.js +11 -3
- package/lib/cli.js +19 -21
- package/lib/concordance-options.js +1 -1
- package/lib/fork.js +79 -23
- package/lib/globs.js +1 -5
- package/lib/ipc-flow-control.js +22 -25
- package/lib/load-config.js +125 -18
- package/lib/plugin-support/shared-worker-loader.js +252 -0
- package/lib/plugin-support/shared-workers.js +140 -0
- package/lib/reporters/default.js +33 -2
- package/lib/reporters/tap.js +12 -2
- package/lib/run-status.js +5 -0
- package/lib/runner.js +53 -9
- package/lib/snapshot-manager.js +67 -9
- package/lib/test.js +20 -12
- package/lib/worker/ipc.js +171 -26
- package/lib/worker/plugin.js +121 -0
- package/lib/worker/subprocess.js +24 -1
- package/package.json +35 -31
- package/plugin.d.ts +79 -0
- package/plugin.js +9 -0
- package/readme.md +2 -7
package/lib/worker/subprocess.js
CHANGED
|
@@ -32,6 +32,8 @@ ipc.options.then(async options => {
|
|
|
32
32
|
const dependencyTracking = require('./dependency-tracker');
|
|
33
33
|
const lineNumberSelection = require('./line-numbers');
|
|
34
34
|
|
|
35
|
+
const sharedWorkerTeardowns = [];
|
|
36
|
+
|
|
35
37
|
async function exit(code) {
|
|
36
38
|
if (!process.exitCode) {
|
|
37
39
|
process.exitCode = code;
|
|
@@ -89,7 +91,7 @@ ipc.options.then(async options => {
|
|
|
89
91
|
exit(1);
|
|
90
92
|
});
|
|
91
93
|
|
|
92
|
-
runner.on('finish', () => {
|
|
94
|
+
runner.on('finish', async () => {
|
|
93
95
|
try {
|
|
94
96
|
const {cannotSave, touchedFiles} = runner.saveSnapshotState();
|
|
95
97
|
if (cannotSave) {
|
|
@@ -103,6 +105,14 @@ ipc.options.then(async options => {
|
|
|
103
105
|
return;
|
|
104
106
|
}
|
|
105
107
|
|
|
108
|
+
try {
|
|
109
|
+
await Promise.all(sharedWorkerTeardowns.map(fn => fn()));
|
|
110
|
+
} catch (error) {
|
|
111
|
+
ipc.send({type: 'uncaught-exception', err: serializeError('Shared worker teardown error', false, error, runner.file)});
|
|
112
|
+
exit(1);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
106
116
|
nowAndTimers.setImmediate(() => {
|
|
107
117
|
currentlyUnhandled()
|
|
108
118
|
.filter(rejection => !attributedRejections.has(rejection.promise))
|
|
@@ -129,6 +139,19 @@ ipc.options.then(async options => {
|
|
|
129
139
|
return runner;
|
|
130
140
|
};
|
|
131
141
|
|
|
142
|
+
exports.registerSharedWorker = (filename, initialData, teardown) => {
|
|
143
|
+
const {channel, forceUnref, ready} = ipc.registerSharedWorker(filename, initialData);
|
|
144
|
+
runner.waitForReady.push(ready);
|
|
145
|
+
sharedWorkerTeardowns.push(async () => {
|
|
146
|
+
try {
|
|
147
|
+
await teardown();
|
|
148
|
+
} finally {
|
|
149
|
+
forceUnref();
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
return channel;
|
|
153
|
+
};
|
|
154
|
+
|
|
132
155
|
// Store value to prevent required modules from modifying it.
|
|
133
156
|
const testPath = options.file;
|
|
134
157
|
|
package/package.json
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ava",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"description": "Node.js test runner that lets you develop with confidence.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "avajs/ava",
|
|
7
7
|
"homepage": "https://avajs.dev",
|
|
8
8
|
"bin": "cli.js",
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": ">=10.18.0 <11 || >=12.14.0 <12.17.0 || >=12.17.0 <13 || >=14.0.0"
|
|
10
|
+
"node": ">=10.18.0 <11 || >=12.14.0 <12.17.0 || >=12.17.0 <13 || >=14.0.0 <15 || >=15"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"
|
|
13
|
+
"cover": "c8 --report=none tap && c8 --report=none --no-clean test-ava && c8 report",
|
|
14
|
+
"test": "xo && tsd && npm run -s cover"
|
|
14
15
|
},
|
|
15
16
|
"files": [
|
|
16
17
|
"lib",
|
|
17
18
|
"*.js",
|
|
18
19
|
"!*.config.js",
|
|
19
|
-
"index.d.ts"
|
|
20
|
+
"index.d.ts",
|
|
21
|
+
"*.d.ts"
|
|
20
22
|
],
|
|
21
23
|
"keywords": [
|
|
22
24
|
"π¦",
|
|
@@ -56,14 +58,14 @@
|
|
|
56
58
|
],
|
|
57
59
|
"dependencies": {
|
|
58
60
|
"@concordance/react": "^2.0.0",
|
|
59
|
-
"acorn": "^8.0.
|
|
61
|
+
"acorn": "^8.0.4",
|
|
60
62
|
"acorn-walk": "^8.0.0",
|
|
61
|
-
"ansi-styles": "^
|
|
63
|
+
"ansi-styles": "^5.0.0",
|
|
62
64
|
"arrgv": "^1.0.2",
|
|
63
65
|
"arrify": "^2.0.1",
|
|
64
66
|
"callsites": "^3.1.0",
|
|
65
67
|
"chalk": "^4.1.0",
|
|
66
|
-
"chokidar": "^3.4.
|
|
68
|
+
"chokidar": "^3.4.3",
|
|
67
69
|
"chunkd": "^2.0.1",
|
|
68
70
|
"ci-info": "^2.0.0",
|
|
69
71
|
"ci-parallel-vars": "^1.0.1",
|
|
@@ -75,9 +77,9 @@
|
|
|
75
77
|
"concordance": "^5.0.1",
|
|
76
78
|
"convert-source-map": "^1.7.0",
|
|
77
79
|
"currently-unhandled": "^0.4.1",
|
|
78
|
-
"debug": "^4.
|
|
79
|
-
"del": "^
|
|
80
|
-
"emittery": "^0.
|
|
80
|
+
"debug": "^4.3.1",
|
|
81
|
+
"del": "^6.0.0",
|
|
82
|
+
"emittery": "^0.8.0",
|
|
81
83
|
"equal-length": "^1.0.0",
|
|
82
84
|
"figures": "^3.2.0",
|
|
83
85
|
"globby": "^11.0.1",
|
|
@@ -85,57 +87,59 @@
|
|
|
85
87
|
"import-local": "^3.0.2",
|
|
86
88
|
"indent-string": "^4.0.0",
|
|
87
89
|
"is-error": "^2.2.2",
|
|
88
|
-
"is-plain-object": "^
|
|
90
|
+
"is-plain-object": "^5.0.0",
|
|
89
91
|
"is-promise": "^4.0.0",
|
|
90
92
|
"lodash": "^4.17.20",
|
|
91
93
|
"matcher": "^3.0.0",
|
|
92
94
|
"md5-hex": "^3.0.1",
|
|
93
|
-
"mem": "^
|
|
94
|
-
"ms": "^2.1.
|
|
95
|
-
"ora": "^5.
|
|
95
|
+
"mem": "^8.0.0",
|
|
96
|
+
"ms": "^2.1.3",
|
|
97
|
+
"ora": "^5.2.0",
|
|
98
|
+
"p-event": "^4.2.0",
|
|
96
99
|
"p-map": "^4.0.0",
|
|
97
100
|
"picomatch": "^2.2.2",
|
|
98
101
|
"pkg-conf": "^3.1.0",
|
|
99
102
|
"plur": "^4.0.0",
|
|
100
|
-
"pretty-ms": "^7.0.
|
|
103
|
+
"pretty-ms": "^7.0.1",
|
|
101
104
|
"read-pkg": "^5.2.0",
|
|
102
105
|
"resolve-cwd": "^3.0.0",
|
|
103
106
|
"slash": "^3.0.0",
|
|
104
107
|
"source-map-support": "^0.5.19",
|
|
105
|
-
"stack-utils": "^2.0.
|
|
108
|
+
"stack-utils": "^2.0.3",
|
|
106
109
|
"strip-ansi": "^6.0.0",
|
|
107
|
-
"supertap": "^
|
|
110
|
+
"supertap": "^2.0.0",
|
|
108
111
|
"temp-dir": "^2.0.0",
|
|
109
112
|
"trim-off-newlines": "^1.0.1",
|
|
110
|
-
"update-notifier": "^
|
|
113
|
+
"update-notifier": "^5.0.1",
|
|
111
114
|
"write-file-atomic": "^3.0.3",
|
|
112
|
-
"yargs": "^
|
|
115
|
+
"yargs": "^16.2.0"
|
|
113
116
|
},
|
|
114
117
|
"devDependencies": {
|
|
115
118
|
"@ava/babel": "^1.0.1",
|
|
116
119
|
"@ava/test": "github:avajs/test",
|
|
117
|
-
"@babel/plugin-proposal-do-expressions": "^7.
|
|
120
|
+
"@babel/plugin-proposal-do-expressions": "^7.12.1",
|
|
118
121
|
"@sinonjs/fake-timers": "^6.0.1",
|
|
119
122
|
"ansi-escapes": "^4.3.1",
|
|
120
|
-
"c8": "^7.
|
|
123
|
+
"c8": "^7.4.0",
|
|
121
124
|
"delay": "^4.4.0",
|
|
122
125
|
"esm": "^3.2.25",
|
|
123
|
-
"execa": "^
|
|
126
|
+
"execa": "^5.0.0",
|
|
127
|
+
"fs-extra": "^9.0.1",
|
|
124
128
|
"get-stream": "^6.0.0",
|
|
125
|
-
"
|
|
129
|
+
"it-first": "^1.0.4",
|
|
126
130
|
"proxyquire": "^2.1.3",
|
|
127
|
-
"react": "^16.
|
|
128
|
-
"react-test-renderer": "^16.
|
|
131
|
+
"react": "^16.14.0",
|
|
132
|
+
"react-test-renderer": "^16.14.0",
|
|
129
133
|
"replace-string": "^3.1.0",
|
|
130
|
-
"sinon": "^9.
|
|
134
|
+
"sinon": "^9.2.2",
|
|
131
135
|
"source-map-fixtures": "^2.1.0",
|
|
132
|
-
"tap": "^14.
|
|
136
|
+
"tap": "^14.11.0",
|
|
133
137
|
"temp-write": "^4.0.0",
|
|
134
|
-
"tempy": "^0.
|
|
138
|
+
"tempy": "^1.0.0",
|
|
135
139
|
"touch": "^3.1.0",
|
|
136
|
-
"tsd": "^0.
|
|
137
|
-
"typescript": "^
|
|
138
|
-
"xo": "^0.
|
|
140
|
+
"tsd": "^0.14.0",
|
|
141
|
+
"typescript": "^4.1.3",
|
|
142
|
+
"xo": "^0.36.1",
|
|
139
143
|
"zen-observable": "^0.8.15"
|
|
140
144
|
}
|
|
141
145
|
}
|
package/plugin.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export namespace SharedWorker {
|
|
2
|
+
export type ProtocolIdentifier = 'experimental';
|
|
3
|
+
|
|
4
|
+
export type FactoryOptions = {
|
|
5
|
+
negotiateProtocol <Data = unknown>(supported: readonly ['experimental']): Experimental.Protocol<Data>;
|
|
6
|
+
// Add overloads for additional protocols.
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type Factory = (options: FactoryOptions) => void;
|
|
10
|
+
|
|
11
|
+
export namespace Experimental {
|
|
12
|
+
export type Protocol<Data = unknown> = {
|
|
13
|
+
readonly initialData: Data;
|
|
14
|
+
readonly protocol: 'experimental';
|
|
15
|
+
broadcast: (data: Data) => BroadcastMessage<Data>;
|
|
16
|
+
ready: () => Protocol<Data>;
|
|
17
|
+
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
|
|
18
|
+
testWorkers: () => AsyncIterableIterator<TestWorker<Data>>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type BroadcastMessage<Data = unknown> = {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type PublishedMessage<Data = unknown> = {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type ReceivedMessage<Data = unknown> = {
|
|
32
|
+
readonly data: Data;
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly testWorker: TestWorker;
|
|
35
|
+
reply: (data: Data) => PublishedMessage<Data>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type TestWorker<Data = unknown> = {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly file: string;
|
|
41
|
+
publish: (data: Data) => PublishedMessage<Data>;
|
|
42
|
+
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
|
|
43
|
+
teardown: <TeardownFn extends () => void> (fn: TeardownFn) => TeardownFn;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export namespace Plugin {
|
|
48
|
+
export type RegistrationOptions<Identifier extends ProtocolIdentifier, Data = unknown> = {
|
|
49
|
+
readonly filename: string;
|
|
50
|
+
readonly initialData?: Data;
|
|
51
|
+
readonly supportedProtocols: readonly Identifier[];
|
|
52
|
+
readonly teardown?: () => void;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export namespace Experimental {
|
|
56
|
+
export type Protocol<Data = unknown> = {
|
|
57
|
+
readonly available: Promise<void>;
|
|
58
|
+
readonly currentlyAvailable: boolean;
|
|
59
|
+
readonly protocol: 'experimental';
|
|
60
|
+
publish: (data: Data) => PublishedMessage<Data>;
|
|
61
|
+
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type PublishedMessage<Data = unknown> = {
|
|
65
|
+
readonly id: string;
|
|
66
|
+
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type ReceivedMessage<Data = unknown> = {
|
|
70
|
+
readonly data: Data;
|
|
71
|
+
readonly id: string;
|
|
72
|
+
reply: (data: Data) => PublishedMessage<Data>;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function registerSharedWorker<Data = unknown>(options: SharedWorker.Plugin.RegistrationOptions<'experimental', Data>): SharedWorker.Plugin.Experimental.Protocol<Data>;
|
|
79
|
+
// Add overloads for additional protocols.
|
package/plugin.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
// Ensure the same AVA install is loaded by the test file as by the test worker
|
|
5
|
+
if (process.env.AVA_PATH && process.env.AVA_PATH !== __dirname) {
|
|
6
|
+
module.exports = require(path.join(process.env.AVA_PATH, 'plugin'));
|
|
7
|
+
} else {
|
|
8
|
+
module.exports = require('./lib/worker/plugin');
|
|
9
|
+
}
|
package/readme.md
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# <img src="media/header.png" title="AVA" alt="AVA logo" width="530">
|
|
2
2
|
|
|
3
|
-
[](https://travis-ci.org/avajs/ava) [](https://codecov.io/gh/avajs/ava/branch/master) [](https://github.com/xojs/xo) [](https://spectrum.chat/ava)
|
|
4
|
-
[](https://github.com/sindresorhus/awesome-nodejs)
|
|
5
|
-
|
|
6
3
|
AVA is a test runner for Node.js with a concise API, detailed error output, embrace of new language features and process isolation that lets you develop with confidence π
|
|
7
4
|
|
|
8
5
|
Follow the [AVA Twitter account](https://twitter.com/ava__js) for updates.
|
|
@@ -143,6 +140,7 @@ We have a growing list of [common pitfalls](docs/08-common-pitfalls.md) you may
|
|
|
143
140
|
|
|
144
141
|
### Recipes
|
|
145
142
|
|
|
143
|
+
- [Shared workers](docs/recipes/shared-workers.md)
|
|
146
144
|
- [Test setup](docs/recipes/test-setup.md)
|
|
147
145
|
- [Code coverage](docs/recipes/code-coverage.md)
|
|
148
146
|
- [Watch mode](docs/recipes/watch-mode.md)
|
|
@@ -187,9 +185,7 @@ It's the [Andromeda galaxy](https://simple.wikipedia.org/wiki/Andromeda_galaxy).
|
|
|
187
185
|
|
|
188
186
|
## Support
|
|
189
187
|
|
|
190
|
-
- [
|
|
191
|
-
- [Spectrum](https://spectrum.chat/ava)
|
|
192
|
-
- [Twitter](https://twitter.com/ava__js)
|
|
188
|
+
- [GitHub Discussions](https://github.com/avajs/ava/discussions)
|
|
193
189
|
|
|
194
190
|
## Related
|
|
195
191
|
|
|
@@ -205,7 +201,6 @@ It's the [Andromeda galaxy](https://simple.wikipedia.org/wiki/Andromeda_galaxy).
|
|
|
205
201
|
|
|
206
202
|
- [AVA stickers, t-shirts, etc](https://www.redbubble.com/people/sindresorhus/works/30330590-ava-logo)
|
|
207
203
|
- [Awesome list](https://github.com/avajs/awesome-ava)
|
|
208
|
-
- [AVA Casts](http://avacasts.com)
|
|
209
204
|
- [Do you like AVA? Donate here!](https://opencollective.com/ava)
|
|
210
205
|
- [Moreβ¦](https://github.com/avajs/awesome-ava)
|
|
211
206
|
|