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.
- package/entrypoints/cli.mjs +4 -0
- package/entrypoints/eslint-plugin-helper.cjs +109 -0
- 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 -816
- package/lib/api.js +108 -49
- package/lib/assert.js +255 -270
- package/lib/chalk.js +9 -14
- package/lib/cli.js +118 -112
- package/lib/code-excerpt.js +12 -17
- package/lib/concordance-options.js +29 -65
- package/lib/context-ref.js +3 -6
- package/lib/create-chain.js +32 -20
- package/lib/environment-variables.js +1 -4
- package/lib/eslint-plugin-helper-worker.js +73 -0
- package/lib/extensions.js +2 -2
- package/lib/fork.js +81 -84
- 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 +11 -18
- package/lib/load-config.js +56 -180
- package/lib/module-types.js +3 -7
- 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 -46
- package/lib/provider-manager.js +20 -14
- package/lib/reporters/beautify-stack.js +6 -12
- package/lib/reporters/colors.js +40 -15
- package/lib/reporters/default.js +114 -364
- 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 +18 -25
- package/lib/run-status.js +29 -23
- package/lib/runner.js +157 -172
- package/lib/scheduler.js +53 -0
- package/lib/serialize-error.js +61 -64
- package/lib/snapshot-manager.js +271 -289
- package/lib/test.js +135 -291
- package/lib/watcher.js +69 -44
- package/lib/worker/base.js +208 -0
- package/lib/worker/channel.cjs +290 -0
- package/lib/worker/dependency-tracker.js +24 -23
- package/lib/worker/{ensure-forked.js → guard-environment.cjs} +5 -4
- package/lib/worker/line-numbers.js +58 -20
- package/lib/worker/main.cjs +12 -0
- package/lib/worker/{options.js → options.cjs} +0 -0
- package/lib/worker/{plugin.js → plugin.cjs} +30 -21
- package/lib/worker/state.cjs +5 -0
- package/lib/worker/utils.cjs +6 -0
- package/package.json +71 -68
- package/plugin.d.ts +51 -53
- package/readme.md +5 -13
- 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/eslint-plugin-helper.js +0 -201
- package/index.js +0 -8
- package/lib/worker/ipc.js +0 -201
- package/lib/worker/main.js +0 -21
- package/lib/worker/subprocess.js +0 -266
- package/plugin.js +0 -9
package/package.json
CHANGED
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ava",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.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
|
-
"bin":
|
|
8
|
+
"bin": {
|
|
9
|
+
"ava": "entrypoints/cli.mjs"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./entrypoints/main.mjs",
|
|
14
|
+
"require": "./entrypoints/main.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./eslint-plugin-helper": "./entrypoints/eslint-plugin-helper.cjs",
|
|
17
|
+
"./plugin": {
|
|
18
|
+
"import": "./entrypoints/plugin.mjs",
|
|
19
|
+
"require": "./entrypoints/plugin.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
9
23
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
24
|
+
"node": ">=12.22 <13 || >=14.17 <15 || >=16.4 <17 || >=17"
|
|
11
25
|
},
|
|
12
26
|
"scripts": {
|
|
13
|
-
"cover": "c8 --report=none
|
|
27
|
+
"cover": "c8 --report=none test-ava && c8 --report=none --no-clean tap && c8 report",
|
|
14
28
|
"test": "xo && tsd && npm run -s cover"
|
|
15
29
|
},
|
|
16
30
|
"files": [
|
|
31
|
+
"entrypoints",
|
|
17
32
|
"lib",
|
|
18
|
-
"
|
|
19
|
-
"!*.config.js",
|
|
33
|
+
"types",
|
|
20
34
|
"index.d.ts",
|
|
21
|
-
"
|
|
35
|
+
"plugin.d.ts"
|
|
22
36
|
],
|
|
23
37
|
"keywords": [
|
|
24
38
|
"🦄",
|
|
@@ -38,7 +52,6 @@
|
|
|
38
52
|
"tap",
|
|
39
53
|
"qunit",
|
|
40
54
|
"jasmine",
|
|
41
|
-
"babel",
|
|
42
55
|
"assert",
|
|
43
56
|
"assertion",
|
|
44
57
|
"promise",
|
|
@@ -57,89 +70,79 @@
|
|
|
57
70
|
"typescript"
|
|
58
71
|
],
|
|
59
72
|
"dependencies": {
|
|
60
|
-
"
|
|
61
|
-
"acorn": "^8.0
|
|
62
|
-
"
|
|
63
|
-
"ansi-styles": "^5.0.0",
|
|
73
|
+
"acorn": "^8.7.0",
|
|
74
|
+
"acorn-walk": "^8.2.0",
|
|
75
|
+
"ansi-styles": "^6.1.0",
|
|
64
76
|
"arrgv": "^1.0.2",
|
|
65
|
-
"arrify": "^
|
|
66
|
-
"callsites": "^
|
|
67
|
-
"
|
|
68
|
-
"
|
|
77
|
+
"arrify": "^3.0.0",
|
|
78
|
+
"callsites": "^4.0.0",
|
|
79
|
+
"cbor": "^8.1.0",
|
|
80
|
+
"chalk": "^5.0.0",
|
|
81
|
+
"chokidar": "^3.5.2",
|
|
69
82
|
"chunkd": "^2.0.1",
|
|
70
|
-
"ci-info": "^
|
|
83
|
+
"ci-info": "^3.3.0",
|
|
71
84
|
"ci-parallel-vars": "^1.0.1",
|
|
72
85
|
"clean-yaml-object": "^0.1.0",
|
|
73
|
-
"cli-
|
|
74
|
-
"cli-truncate": "^2.1.0",
|
|
86
|
+
"cli-truncate": "^3.1.0",
|
|
75
87
|
"code-excerpt": "^3.0.0",
|
|
76
88
|
"common-path-prefix": "^3.0.0",
|
|
77
|
-
"concordance": "^5.0.
|
|
78
|
-
"convert-source-map": "^1.7.0",
|
|
89
|
+
"concordance": "^5.0.4",
|
|
79
90
|
"currently-unhandled": "^0.4.1",
|
|
80
|
-
"debug": "^4.3.
|
|
91
|
+
"debug": "^4.3.3",
|
|
81
92
|
"del": "^6.0.0",
|
|
82
|
-
"emittery": "^0.
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"globby": "^11.0.1",
|
|
93
|
+
"emittery": "^0.10.0",
|
|
94
|
+
"figures": "^4.0.0",
|
|
95
|
+
"globby": "^12.0.2",
|
|
86
96
|
"ignore-by-default": "^2.0.0",
|
|
87
|
-
"
|
|
88
|
-
"indent-string": "^4.0.0",
|
|
97
|
+
"indent-string": "^5.0.0",
|
|
89
98
|
"is-error": "^2.2.2",
|
|
90
99
|
"is-plain-object": "^5.0.0",
|
|
91
100
|
"is-promise": "^4.0.0",
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"md5-hex": "^3.0.1",
|
|
95
|
-
"mem": "^8.0.0",
|
|
101
|
+
"matcher": "^5.0.0",
|
|
102
|
+
"mem": "^9.0.1",
|
|
96
103
|
"ms": "^2.1.3",
|
|
97
|
-
"
|
|
98
|
-
"p-
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"plur": "^4.0.0",
|
|
104
|
+
"p-event": "^5.0.1",
|
|
105
|
+
"p-map": "^5.3.0",
|
|
106
|
+
"picomatch": "^2.3.0",
|
|
107
|
+
"pkg-conf": "^4.0.0",
|
|
108
|
+
"plur": "^5.1.0",
|
|
103
109
|
"pretty-ms": "^7.0.1",
|
|
104
|
-
"read-pkg": "^5.2.0",
|
|
105
110
|
"resolve-cwd": "^3.0.0",
|
|
106
111
|
"slash": "^3.0.0",
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"strip-ansi": "^6.0.0",
|
|
112
|
+
"stack-utils": "^2.0.5",
|
|
113
|
+
"strip-ansi": "^7.0.1",
|
|
110
114
|
"supertap": "^2.0.0",
|
|
111
115
|
"temp-dir": "^2.0.0",
|
|
112
|
-
"trim-off-newlines": "^1.0.1",
|
|
113
|
-
"update-notifier": "^5.0.1",
|
|
114
116
|
"write-file-atomic": "^3.0.3",
|
|
115
|
-
"yargs": "^
|
|
117
|
+
"yargs": "^17.3.1"
|
|
116
118
|
},
|
|
117
119
|
"devDependencies": {
|
|
118
|
-
"@ava/babel": "^1.0.1",
|
|
119
120
|
"@ava/test": "github:avajs/test",
|
|
120
|
-
"@
|
|
121
|
-
"@sinonjs/fake-timers": "^
|
|
122
|
-
"ansi-escapes": "^
|
|
123
|
-
"c8": "^7.
|
|
124
|
-
"delay": "^
|
|
125
|
-
"
|
|
126
|
-
"
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
"
|
|
133
|
-
"replace-string": "^3.1.0",
|
|
134
|
-
"sinon": "^9.2.2",
|
|
135
|
-
"source-map-fixtures": "^2.1.0",
|
|
136
|
-
"tap": "^14.11.0",
|
|
137
|
-
"temp-write": "^4.0.0",
|
|
138
|
-
"tempy": "^1.0.0",
|
|
121
|
+
"@ava/typescript": "^3.0.1",
|
|
122
|
+
"@sinonjs/fake-timers": "^8.1.0",
|
|
123
|
+
"ansi-escapes": "^5.0.0",
|
|
124
|
+
"c8": "^7.11.0",
|
|
125
|
+
"delay": "^5.0.0",
|
|
126
|
+
"execa": "^6.0.0",
|
|
127
|
+
"fs-extra": "^10.0.0",
|
|
128
|
+
"get-stream": "^6.0.1",
|
|
129
|
+
"replace-string": "^4.0.0",
|
|
130
|
+
"sinon": "^12.0.1",
|
|
131
|
+
"tap": "^15.1.5",
|
|
132
|
+
"temp-write": "^5.0.0",
|
|
133
|
+
"tempy": "^2.0.0",
|
|
139
134
|
"touch": "^3.1.0",
|
|
140
|
-
"tsd": "^0.
|
|
141
|
-
"typescript": "^4.
|
|
142
|
-
"xo": "^0.
|
|
135
|
+
"tsd": "^0.19.1",
|
|
136
|
+
"typescript": "^4.4.4",
|
|
137
|
+
"xo": "^0.47.0",
|
|
143
138
|
"zen-observable": "^0.8.15"
|
|
139
|
+
},
|
|
140
|
+
"peerDependencies": {
|
|
141
|
+
"@ava/typescript": "*"
|
|
142
|
+
},
|
|
143
|
+
"peerDependenciesMeta": {
|
|
144
|
+
"@ava/typescript": {
|
|
145
|
+
"optional": true
|
|
146
|
+
}
|
|
144
147
|
}
|
|
145
148
|
}
|
package/plugin.d.ts
CHANGED
|
@@ -1,79 +1,77 @@
|
|
|
1
|
+
import {URL} from 'node:url';
|
|
2
|
+
|
|
1
3
|
export namespace SharedWorker {
|
|
2
|
-
export type ProtocolIdentifier = '
|
|
4
|
+
export type ProtocolIdentifier = 'ava-4';
|
|
3
5
|
|
|
4
6
|
export type FactoryOptions = {
|
|
5
|
-
negotiateProtocol <Data = unknown>(supported: readonly ['
|
|
7
|
+
negotiateProtocol <Data = unknown>(supported: readonly ['ava-4']): Protocol<Data>;
|
|
6
8
|
// Add overloads for additional protocols.
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
export type Factory = (options: FactoryOptions) => void;
|
|
10
12
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
13
|
+
export type Protocol<Data = unknown> = {
|
|
14
|
+
readonly initialData: Data;
|
|
15
|
+
readonly protocol: 'ava-4';
|
|
16
|
+
broadcast: (data: Data) => BroadcastMessage<Data>;
|
|
17
|
+
ready: () => Protocol<Data>;
|
|
18
|
+
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
|
|
19
|
+
testWorkers: () => AsyncIterableIterator<TestWorker<Data>>;
|
|
20
|
+
};
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
export type BroadcastMessage<Data = unknown> = {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
|
|
25
|
+
};
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
export type PublishedMessage<Data = unknown> = {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
|
|
30
|
+
};
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
export type ReceivedMessage<Data = unknown> = {
|
|
33
|
+
readonly data: Data;
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly testWorker: TestWorker;
|
|
36
|
+
reply: (data: Data) => PublishedMessage<Data>;
|
|
37
|
+
};
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
39
|
+
export type TestWorker<Data = unknown> = {
|
|
40
|
+
readonly id: string;
|
|
41
|
+
readonly file: string;
|
|
42
|
+
publish: (data: Data) => PublishedMessage<Data>;
|
|
43
|
+
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
|
|
44
|
+
teardown: <TeardownFn extends () => void> (fn: TeardownFn) => TeardownFn;
|
|
45
|
+
};
|
|
46
46
|
|
|
47
47
|
export namespace Plugin {
|
|
48
48
|
export type RegistrationOptions<Identifier extends ProtocolIdentifier, Data = unknown> = {
|
|
49
|
-
readonly filename: string;
|
|
49
|
+
readonly filename: string | URL;
|
|
50
50
|
readonly initialData?: Data;
|
|
51
51
|
readonly supportedProtocols: readonly Identifier[];
|
|
52
52
|
readonly teardown?: () => void;
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
55
|
+
export type Protocol<Data = unknown> = {
|
|
56
|
+
readonly available: Promise<void>;
|
|
57
|
+
readonly currentlyAvailable: boolean;
|
|
58
|
+
readonly protocol: 'ava-4';
|
|
59
|
+
publish: (data: Data) => PublishedMessage<Data>;
|
|
60
|
+
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
|
|
61
|
+
};
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
export type PublishedMessage<Data = unknown> = {
|
|
64
|
+
readonly id: string;
|
|
65
|
+
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
|
|
66
|
+
};
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
68
|
+
export type ReceivedMessage<Data = unknown> = {
|
|
69
|
+
readonly data: Data;
|
|
70
|
+
readonly id: string;
|
|
71
|
+
reply: (data: Data) => PublishedMessage<Data>;
|
|
72
|
+
};
|
|
75
73
|
}
|
|
76
74
|
}
|
|
77
75
|
|
|
78
|
-
export function registerSharedWorker<Data = unknown>(options: SharedWorker.Plugin.RegistrationOptions<'
|
|
76
|
+
export function registerSharedWorker<Data = unknown>(options: SharedWorker.Plugin.RegistrationOptions<'ava-4', Data>): SharedWorker.Plugin.Protocol<Data>;
|
|
79
77
|
// Add overloads for additional protocols.
|
package/readme.md
CHANGED
|
@@ -6,7 +6,7 @@ Follow the [AVA Twitter account](https://twitter.com/ava__js) for updates.
|
|
|
6
6
|
|
|
7
7
|
Read our [contributing guide](.github/CONTRIBUTING.md) if you're looking to contribute (issues / PRs / etc).
|
|
8
8
|
|
|
9
|
-

|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
Translations: [Español](https://github.com/avajs/ava-docs/blob/master/es_ES/readme.md), [Français](https://github.com/avajs/ava-docs/blob/master/fr_FR/readme.md), [Italiano](https://github.com/avajs/ava-docs/blob/master/it_IT/readme.md), [日本語](https://github.com/avajs/ava-docs/blob/master/ja_JP/readme.md), [한국어](https://github.com/avajs/ava-docs/blob/master/ko_KR/readme.md), [Português](https://github.com/avajs/ava-docs/blob/master/pt_BR/readme.md), [Русский](https://github.com/avajs/ava-docs/blob/master/ru_RU/readme.md), [简体中文](https://github.com/avajs/ava-docs/blob/master/zh_CN/readme.md)
|
|
@@ -22,7 +22,6 @@ Translations: [Español](https://github.com/avajs/ava-docs/blob/master/es_ES/rea
|
|
|
22
22
|
- Includes TypeScript definitions
|
|
23
23
|
- [Magic assert](#magic-assert)
|
|
24
24
|
- [Isolated environment for each test file](./docs/01-writing-tests.md#process-isolation)
|
|
25
|
-
- [Write your tests using the latest JavaScript syntax](https://github.com/avajs/babel)
|
|
26
25
|
- [Promise support](./docs/01-writing-tests.md#promise-support)
|
|
27
26
|
- [Async function support](./docs/01-writing-tests.md#async-function-support)
|
|
28
27
|
- [Observable support](./docs/01-writing-tests.md#observable-support)
|
|
@@ -148,11 +147,7 @@ We have a growing list of [common pitfalls](docs/08-common-pitfalls.md) you may
|
|
|
148
147
|
- [When to use `t.plan()`](docs/recipes/when-to-use-plan.md)
|
|
149
148
|
- [Browser testing](docs/recipes/browser-testing.md)
|
|
150
149
|
- [TypeScript](docs/recipes/typescript.md)
|
|
151
|
-
- [Flow](docs/recipes/flow.md)
|
|
152
|
-
- [Configuring Babel](https://github.com/avajs/babel)
|
|
153
|
-
- [Using ES modules](docs/recipes/es-modules.md)
|
|
154
150
|
- [Passing arguments to your test files](docs/recipes/passing-arguments-to-your-test-files.md)
|
|
155
|
-
- [Testing React components](docs/recipes/react.md)
|
|
156
151
|
- [Testing Vue.js components](docs/recipes/vue.md)
|
|
157
152
|
- [Debugging tests with Chrome DevTools](docs/recipes/debugging-with-chrome-devtools.md)
|
|
158
153
|
- [Debugging tests with VSCode](docs/recipes/debugging-with-vscode.md)
|
|
@@ -189,13 +184,10 @@ It's the [Andromeda galaxy](https://simple.wikipedia.org/wiki/Andromeda_galaxy).
|
|
|
189
184
|
|
|
190
185
|
## Related
|
|
191
186
|
|
|
192
|
-
- [eslint-plugin-ava](https://github.com/avajs/eslint-plugin-ava)
|
|
193
|
-
- [
|
|
194
|
-
- [
|
|
195
|
-
- [
|
|
196
|
-
- [gulp-ava](https://github.com/avajs/gulp-ava) - Run tests with gulp
|
|
197
|
-
- [grunt-ava](https://github.com/avajs/grunt-ava) - Run tests with grunt
|
|
198
|
-
- [More…](https://github.com/avajs/awesome-ava#packages)
|
|
187
|
+
- [eslint-plugin-ava](https://github.com/avajs/eslint-plugin-ava) — Lint rules for AVA tests
|
|
188
|
+
- [@ava/typescript](https://github.com/avajs/typescript) — Test TypeScript projects
|
|
189
|
+
- [@ava/cooperate](https://github.com/avajs/cooperate) — Low-level primitives to enable cooperation between test files
|
|
190
|
+
- [@ava/get-port](https://github.com/avajs/get-port) — Reserve a port while testing
|
|
199
191
|
|
|
200
192
|
## Links
|
|
201
193
|
|