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.
Files changed (72) hide show
  1. package/entrypoints/cli.mjs +4 -0
  2. package/entrypoints/eslint-plugin-helper.cjs +109 -0
  3. package/entrypoints/main.cjs +2 -0
  4. package/entrypoints/main.mjs +1 -0
  5. package/entrypoints/plugin.cjs +2 -0
  6. package/entrypoints/plugin.mjs +4 -0
  7. package/index.d.ts +6 -816
  8. package/lib/api.js +108 -49
  9. package/lib/assert.js +255 -270
  10. package/lib/chalk.js +9 -14
  11. package/lib/cli.js +118 -112
  12. package/lib/code-excerpt.js +12 -17
  13. package/lib/concordance-options.js +29 -65
  14. package/lib/context-ref.js +3 -6
  15. package/lib/create-chain.js +32 -20
  16. package/lib/environment-variables.js +1 -4
  17. package/lib/eslint-plugin-helper-worker.js +73 -0
  18. package/lib/extensions.js +2 -2
  19. package/lib/fork.js +81 -84
  20. package/lib/glob-helpers.cjs +140 -0
  21. package/lib/globs.js +136 -163
  22. package/lib/{ipc-flow-control.js → ipc-flow-control.cjs} +1 -0
  23. package/lib/is-ci.js +4 -2
  24. package/lib/like-selector.js +7 -13
  25. package/lib/line-numbers.js +11 -18
  26. package/lib/load-config.js +56 -180
  27. package/lib/module-types.js +3 -7
  28. package/lib/node-arguments.js +4 -5
  29. package/lib/{now-and-timers.js → now-and-timers.cjs} +0 -0
  30. package/lib/parse-test-args.js +22 -11
  31. package/lib/pkg.cjs +2 -0
  32. package/lib/plugin-support/shared-worker-loader.js +45 -48
  33. package/lib/plugin-support/shared-workers.js +24 -46
  34. package/lib/provider-manager.js +20 -14
  35. package/lib/reporters/beautify-stack.js +6 -12
  36. package/lib/reporters/colors.js +40 -15
  37. package/lib/reporters/default.js +114 -364
  38. package/lib/reporters/format-serialized-error.js +7 -18
  39. package/lib/reporters/improper-usage-messages.js +8 -9
  40. package/lib/reporters/prefix-title.js +17 -15
  41. package/lib/reporters/tap.js +18 -25
  42. package/lib/run-status.js +29 -23
  43. package/lib/runner.js +157 -172
  44. package/lib/scheduler.js +53 -0
  45. package/lib/serialize-error.js +61 -64
  46. package/lib/snapshot-manager.js +271 -289
  47. package/lib/test.js +135 -291
  48. package/lib/watcher.js +69 -44
  49. package/lib/worker/base.js +208 -0
  50. package/lib/worker/channel.cjs +290 -0
  51. package/lib/worker/dependency-tracker.js +24 -23
  52. package/lib/worker/{ensure-forked.js → guard-environment.cjs} +5 -4
  53. package/lib/worker/line-numbers.js +58 -20
  54. package/lib/worker/main.cjs +12 -0
  55. package/lib/worker/{options.js → options.cjs} +0 -0
  56. package/lib/worker/{plugin.js → plugin.cjs} +30 -21
  57. package/lib/worker/state.cjs +5 -0
  58. package/lib/worker/utils.cjs +6 -0
  59. package/package.json +71 -68
  60. package/plugin.d.ts +51 -53
  61. package/readme.md +5 -13
  62. package/types/assertions.d.ts +327 -0
  63. package/types/subscribable.ts +6 -0
  64. package/types/test-fn.d.ts +231 -0
  65. package/types/try-fn.d.ts +58 -0
  66. package/cli.js +0 -11
  67. package/eslint-plugin-helper.js +0 -201
  68. package/index.js +0 -8
  69. package/lib/worker/ipc.js +0 -201
  70. package/lib/worker/main.js +0 -21
  71. package/lib/worker/subprocess.js +0 -266
  72. package/plugin.js +0 -9
package/package.json CHANGED
@@ -1,24 +1,38 @@
1
1
  {
2
2
  "name": "ava",
3
- "version": "3.15.0",
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": "cli.js",
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": ">=10.18.0 <11 || >=12.14.0 <12.17.0 || >=12.17.0 <13 || >=14.0.0 <15 || >=15"
24
+ "node": ">=12.22 <13 || >=14.17 <15 || >=16.4 <17 || >=17"
11
25
  },
12
26
  "scripts": {
13
- "cover": "c8 --report=none tap && c8 --report=none --no-clean test-ava && c8 report",
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
- "*.js",
19
- "!*.config.js",
33
+ "types",
20
34
  "index.d.ts",
21
- "*.d.ts"
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
- "@concordance/react": "^2.0.0",
61
- "acorn": "^8.0.4",
62
- "acorn-walk": "^8.0.0",
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": "^2.0.1",
66
- "callsites": "^3.1.0",
67
- "chalk": "^4.1.0",
68
- "chokidar": "^3.4.3",
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": "^2.0.0",
83
+ "ci-info": "^3.3.0",
71
84
  "ci-parallel-vars": "^1.0.1",
72
85
  "clean-yaml-object": "^0.1.0",
73
- "cli-cursor": "^3.1.0",
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.1",
78
- "convert-source-map": "^1.7.0",
89
+ "concordance": "^5.0.4",
79
90
  "currently-unhandled": "^0.4.1",
80
- "debug": "^4.3.1",
91
+ "debug": "^4.3.3",
81
92
  "del": "^6.0.0",
82
- "emittery": "^0.8.0",
83
- "equal-length": "^1.0.0",
84
- "figures": "^3.2.0",
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
- "import-local": "^3.0.2",
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
- "lodash": "^4.17.20",
93
- "matcher": "^3.0.0",
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
- "ora": "^5.2.0",
98
- "p-event": "^4.2.0",
99
- "p-map": "^4.0.0",
100
- "picomatch": "^2.2.2",
101
- "pkg-conf": "^3.1.0",
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
- "source-map-support": "^0.5.19",
108
- "stack-utils": "^2.0.3",
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": "^16.2.0"
117
+ "yargs": "^17.3.1"
116
118
  },
117
119
  "devDependencies": {
118
- "@ava/babel": "^1.0.1",
119
120
  "@ava/test": "github:avajs/test",
120
- "@babel/plugin-proposal-do-expressions": "^7.12.1",
121
- "@sinonjs/fake-timers": "^6.0.1",
122
- "ansi-escapes": "^4.3.1",
123
- "c8": "^7.4.0",
124
- "delay": "^4.4.0",
125
- "esm": "^3.2.25",
126
- "execa": "^5.0.0",
127
- "fs-extra": "^9.0.1",
128
- "get-stream": "^6.0.0",
129
- "it-first": "^1.0.4",
130
- "proxyquire": "^2.1.3",
131
- "react": "^16.14.0",
132
- "react-test-renderer": "^16.14.0",
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.14.0",
141
- "typescript": "^4.1.3",
142
- "xo": "^0.36.1",
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 = 'experimental';
4
+ export type ProtocolIdentifier = 'ava-4';
3
5
 
4
6
  export type FactoryOptions = {
5
- negotiateProtocol <Data = unknown>(supported: readonly ['experimental']): Experimental.Protocol<Data>;
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 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
- };
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
- export type BroadcastMessage<Data = unknown> = {
22
- readonly id: string;
23
- replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
24
- };
22
+ export type BroadcastMessage<Data = unknown> = {
23
+ readonly id: string;
24
+ replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
25
+ };
25
26
 
26
- export type PublishedMessage<Data = unknown> = {
27
- readonly id: string;
28
- replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
29
- };
27
+ export type PublishedMessage<Data = unknown> = {
28
+ readonly id: string;
29
+ replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
30
+ };
30
31
 
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
- };
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
- 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
- }
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 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
- };
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
- export type PublishedMessage<Data = unknown> = {
65
- readonly id: string;
66
- replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
67
- };
63
+ export type PublishedMessage<Data = unknown> = {
64
+ readonly id: string;
65
+ replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
66
+ };
68
67
 
69
- export type ReceivedMessage<Data = unknown> = {
70
- readonly data: Data;
71
- readonly id: string;
72
- reply: (data: Data) => PublishedMessage<Data>;
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<'experimental', Data>): SharedWorker.Plugin.Experimental.Protocol<Data>;
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
- ![](media/mini-reporter.gif)
9
+ ![](media/verbose-reporter.png)
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) - Lint rules for AVA tests
193
- - [sublime-ava](https://github.com/avajs/sublime-ava) - Snippets for AVA tests
194
- - [atom-ava](https://github.com/avajs/atom-ava) - Snippets for AVA tests
195
- - [vscode-ava](https://github.com/samverschueren/vscode-ava) - Snippets for AVA tests
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