Skip to content

Commit 9f3bf7e

Browse files
authored
Remove references to older AVA versions
* Remove obsolete recipes ES modules is supported out of the box. The React recipe applies to AVA 3. * Remove code guards against obsolete API usage * Remove references to older AVA versions from documentation
1 parent 316ffe1 commit 9f3bf7e

15 files changed

+21
-251
lines changed

docs/01-writing-tests.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ AVA tries to run test files with their current working directory set to the dire
1010

1111
## Test isolation
1212

13-
Each test file is run in a new worker thread. This is new as of AVA 4, though you can fall back to AVA 3's behavior of running in separate processes.
13+
By default each test file is run in a new worker thread. You can fall back running in separate processes.
1414

1515
AVA will set `process.env.NODE_ENV` to `test`, unless the `NODE_ENV` environment variable has been set. This is useful if the code you're testing has test defaults (for example when picking what database to connect to). It may cause your code or its dependencies to behave differently though. Note that `'NODE_ENV' in process.env` will always be `true`.
1616

docs/03-assertions.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ test('unicorns are truthy', t => {
2121

2222
If multiple assertion failures are encountered within a single test, AVA will only display the *first* one.
2323

24-
In AVA 6, assertions return `true` if they've passed and throw otherwise. Catching this error does not cause the test to pass. The error value is undocumented.
25-
26-
In AVA 5, assertions return a boolean and do not throw. You can use this to return early from a test. The `snapshot()` assertion does not return a value.
24+
Assertions return `true` if they've passed and throw otherwise. Catching this error does not cause the test to pass. The error value is undocumented.
2725

2826
If you use TypeScript you can use some assertions as type guards.
2927

30-
Note that the "throws" assertions return the error that was thrown (provided the assertion passed). In AVA 5, they return `undefined` if the assertion failed.
28+
Note that the "throws" assertions return the error that was thrown (provided the assertion passed).
3129

3230
## Assertion planning
3331

@@ -179,7 +177,7 @@ t.like([1, 2, 3, 4], [1, , 3])
179177
Assert that an error is thrown. `fn` must be a function which should throw. By default, the thrown value *must* be an error. It is returned so you can run more assertions against it.
180178
`expectation` can be an object with one or more of the following properties:
181179

182-
* `any`: a boolean only available in AVA 6, if `true` then the thrown value does not need to be an error. Defaults to `false`
180+
* `any`: a boolean, if `true` then the thrown value does not need to be an error. Defaults to `false`
183181
* `instanceOf`: a constructor, the thrown error must be an instance of
184182
* `is`: the thrown error must be strictly equal to `expectation.is`
185183
* `message`: the following types are valid:
@@ -214,7 +212,7 @@ Assert that an error is thrown. `thrower` can be an async function which should
214212
By default, the thrown value *must* be an error. It is returned so you can run more assertions against it.
215213
`expectation` can be an object with one or more of the following properties:
216214

217-
* `any`: a boolean only available in AVA 6, if `true` then the thrown value does not need to be an error. Defaults to `false`
215+
* `any`: a boolean, if `true` then the thrown value does not need to be an error. Defaults to `false`
218216
* `instanceOf`: a constructor, the thrown error must be an instance of
219217
* `is`: the thrown error must be strictly equal to `expectation.is`
220218
* `message`: the following types are valid:
@@ -279,7 +277,7 @@ Compares the `expected` value with a previously recorded snapshot. Snapshots are
279277

280278
The implementation function behaves the same as any other test function. You can even use macros. The first title argument is always optional. Additional arguments are passed to the implementation or macro function.
281279

282-
`.try()` is an asynchronous function. You must `await` it. The result object has `commit()` and `discard()` methods. You must decide whether to commit or discard the result. If you commit a failed result, your test will fail. In AVA 6, calling `commit()` on a failed result will throw an error.
280+
`.try()` is an asynchronous function. You must `await` it. The result object has `commit()` and `discard()` methods. You must decide whether to commit or discard the result. If you commit a failed result, your test will fail. Calling `commit()` on a failed result will throw an error.
283281

284282
You can check whether the attempt passed using the `passed` property. Any assertion errors are available through the `errors` property. The attempt title is available through the `title` property.
285283

docs/recipes/es-modules.md

-3
This file was deleted.

docs/recipes/react.md

-189
This file was deleted.

docs/recipes/typescript.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Note that, despite the type cast above, when executing `t.context` is an empty o
177177

178178
## Typing `throws` assertions
179179

180-
In AVA 6, the `t.throws()` and `t.throwsAsync()` assertions are typed to always return an `Error`. You can customize the error class using generics:
180+
The `t.throws()` and `t.throwsAsync()` assertions are typed to always return an `Error`. You can customize the error class using generics:
181181

182182
```ts
183183
import test from 'ava';
@@ -206,6 +206,4 @@ test('throwsAsync', async t => {
206206
});
207207
```
208208

209-
In AVA 5, the assertion is typed to return the `Error` if the assertion passes *or* `undefined` if it fails.
210-
211209
[`@ava/typescript`]: https://github.com/avajs/typescript

docs/recipes/watch-mode.md

+3-9
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,13 @@ Please note that integrated debugging and the TAP reporter are unavailable when
1616

1717
## Requirements
1818

19-
AVA 5 uses [`chokidar`] as the file watcher. Note that even if you see warnings about optional dependencies failing during install, it will still work fine. Please refer to the *[Install Troubleshooting]* section of `chokidar` documentation for how to resolve the installation problems with chokidar.
20-
21-
Otherwise, AVA 6 uses `fs.watch()`. Support for `recursive` mode is required. Note that this has only become available on Linux since Node.js 20. [Other caveats apply](https://nodejs.org/api/fs.html#caveats), for example this won't work well on network filesystems and Docker host mounts.
19+
AVA uses `fs.watch()`. Support for `recursive` mode is required. Note that this has only become available on Linux since Node.js 20. [Other caveats apply](https://nodejs.org/api/fs.html#caveats), for example this won't work well on network filesystems and Docker host mounts.
2220

2321
## Ignoring changes
2422

2523
By default AVA watches for changes to all files, except for those with a `.snap.md` extension, `ava.config.*` and files in [certain directories](https://github.com/novemberborn/ignore-by-default/blob/master/index.js) as provided by the [`ignore-by-default`] package.
2624

27-
With AVA 5, you can configure additional patterns for files to ignore in the [`ava` section of your `package.json`, or `ava.config.*` file][config], using the `ignoredByWatcher` key.
28-
29-
With AVA 6, place these patterns within the `watchMode` object:
25+
You can configure additional patterns for files to ignore in the [`ava` section of your `package.json`, or `ava.config.*` file][config], using the `ignoreChanges` key within the `watchMode` object:
3026

3127
```js
3228
export default {
@@ -42,9 +38,7 @@ If your tests write to disk they may trigger the watcher to rerun your tests. Co
4238

4339
AVA tracks which source files your test files depend on. If you change such a dependency only the test file that depends on it will be rerun. AVA will rerun all tests if it cannot determine which test file depends on the changed source file.
4440

45-
AVA 5 spies on `require()` calls to track dependencies. Custom extensions and transpilers are supported, provided you [added them in your `package.json` or `ava.config.*` file][config], and not from inside your test file.
46-
47-
With AVA 6, dependency tracking works for `require()` and `import` syntax, as supported by [@vercel/nft](https://github.com/vercel/nft). `import()` is supported but dynamic paths such as `import(myVariable)` are not.
41+
Dependency tracking works for `require()` and `import` syntax, as supported by [@vercel/nft](https://github.com/vercel/nft). `import()` is supported but dynamic paths such as `import(myVariable)` are not.
4842

4943
Files accessed using the `fs` module are not tracked.
5044

lib/assert.js

-7
Original file line numberDiff line numberDiff line change
@@ -626,13 +626,6 @@ export class Assertions {
626626
}));
627627
}
628628

629-
if (message?.id !== undefined) {
630-
throw fail(new AssertionError('Since AVA 4, snapshot IDs are no longer supported', {
631-
assertion: 't.snapshot()',
632-
formattedDetails: [formatWithLabel('Called with id:', message.id)],
633-
}));
634-
}
635-
636629
assertMessage(message, 't.snapshot()');
637630

638631
if (message === '') {

lib/runner.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,10 @@ export default class Runner extends Emittery {
123123
todo: true,
124124
});
125125
} else {
126-
if (!implementation) {
126+
if (typeof implementation !== 'function') {
127127
throw new TypeError('Expected an implementation. Use `test.todo()` for tests without an implementation.');
128128
}
129129

130-
if (Array.isArray(implementation)) {
131-
throw new TypeError('AVA 4 no longer supports multiple implementations.');
132-
}
133-
134130
if (title.isSet && !title.isValid) {
135131
throw new TypeError('Test & hook titles must be strings');
136132
}

lib/test.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,10 @@ class ExecutionContext extends Assertions {
9999

100100
const {args, implementation, title} = parseTestArgs(attemptArgs);
101101

102-
if (!implementation) {
102+
if (typeof implementation !== 'function') {
103103
throw new TypeError('Expected an implementation.');
104104
}
105105

106-
if (Array.isArray(implementation)) {
107-
throw new TypeError('AVA 4 no longer supports t.try() with multiple implementations.');
108-
}
109-
110106
let attemptTitle;
111107
if (!title.isSet || title.isEmpty) {
112108
attemptTitle = `${test.title} ─ attempt ${test.attemptCount + 1}`;

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Alternatively you can install `ava` manually:
6969
npm install --save-dev ava
7070
```
7171

72-
*Make sure to install AVA locally. As of AVA 4 it can no longer be run globally.*
72+
*Make sure to install AVA locally. AVA cannot be run globally.*
7373

7474
Don't forget to configure the `test` script in your `package.json` as per above.
7575

test-tap/assert.js

-13
Original file line numberDiff line numberDiff line change
@@ -1538,19 +1538,6 @@ test('.snapshot()', async t => {
15381538
});
15391539
}
15401540

1541-
{
1542-
// See https://github.com/avajs/ava/issues/2669
1543-
const assertions = setup('id');
1544-
failsWith(t, () => assertions.snapshot({foo: 'bar'}, {id: 'an id'}), {
1545-
assertion: 't.snapshot()',
1546-
message: 'Since AVA 4, snapshot IDs are no longer supported',
1547-
formattedDetails: [{
1548-
label: 'Called with id:',
1549-
formatted: '\'an id\'',
1550-
}],
1551-
});
1552-
}
1553-
15541541
await manager.save();
15551542
t.end();
15561543
});

test-tap/reporters/tap.regular.v18.log

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ not ok 12 - test › no longer failing
113113
message: >-
114114
Test was expected to fail, but succeeded, you should stop marking the test as
115115
failing
116-
at: 'Test.finish (/lib/test.js:633:28)'
116+
at: 'Test.finish (/lib/test.js:629:28)'
117117
...
118118
---tty-stream-chunk-separator
119119
not ok 13 - test › logs
@@ -144,7 +144,7 @@ not ok 15 - test › implementation throws non-error
144144
details:
145145
'Error thrown in test:': 'null'
146146
message: Error thrown in test
147-
at: 'Test.run (/lib/test.js:546:25)'
147+
at: 'Test.run (/lib/test.js:542:25)'
148148
...
149149
---tty-stream-chunk-separator
150150
not ok 16 - traces-in-t-throws › throws

0 commit comments

Comments
 (0)