Skip to content

Commit e28e24c

Browse files
committed
readme tweaks
1 parent ea911b6 commit e28e24c

File tree

1 file changed

+13
-47
lines changed

1 file changed

+13
-47
lines changed

readme.md

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> Futuristic test runner
44
5-
[![Build Status: Linux](https://travis-ci.org/sindresorhus/ava.svg?branch=master)](https://travis-ci.org/sindresorhus/ava) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/igogxrcmhhm085co/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/ava/branch/master) [![Coverage Status](https://coveralls.io/repos/sindresorhus/ava/badge.svg?branch=master&service=github)](https://coveralls.io/github/sindresorhus/ava?branch=master) [![Gitter](https://img.shields.io/badge/Gitter-Join_the_AVA_chat_%E2%86%92-00d06f.svg)](https://gitter.im/sindresorhus/ava)
5+
[![Build Status: Linux](https://travis-ci.org/sindresorhus/ava.svg?branch=master)](https://travis-ci.org/sindresorhus/ava) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/igogxrcmhhm085co/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/ava/branch/master) [![Coverage Status](https://coveralls.io/repos/sindresorhus/ava/badge.svg?branch=master&service=github)](https://coveralls.io/github/sindresorhus/ava?branch=master) [![Gitter](https://badges.gitter.im/join chat.svg)](https://gitter.im/sindresorhus/ava)
66

77
Even though JavaScript is single-threaded, IO in Node.js can happen in parallel due to its async nature. AVA takes advantage of this and runs your tests concurrently, which is especially beneficial for IO heavy tests. In addition, test files are run in parallel as separate processes, giving you even better performance and an isolated environment for each test file. [Switching](https://github.com/sindresorhus/pageres/commit/663be15acb3dd2eb0f71b1956ef28c2cd3fdeed0) from Mocha to AVA in Pageres brought the test time down from 31 sec to 11 sec. Having tests run concurrently forces you to write atomic tests, meaning tests don't depend on global state or the state of other tests, which is a great thing!
88

@@ -128,12 +128,12 @@ $ ava --help
128128
test.js test-*.js test/**/*.js
129129
```
130130

131+
*Note that the CLI will use your local install of AVA when available, even when run globally.*
132+
131133
Directories are recursive by default. Directories named `fixtures` and `helpers` are ignored, as well as files starting with `_`. This can be useful for having helpers in the same directory as your test files.
132134

133135
When using `npm test`, you can pass positional arguments directly `npm test test2.js`, but flags needs to be passed like `npm test -- --verbose`.
134136

135-
*WARNING - Non-standard behavior:* The AVA CLI will always try to use your projects local install of AVA. This is true even when you run the global `ava` command. This non-standard behavior solves an important [issue](https://github.com/sindresorhus/ava/issues/157), and should have no impact on everyday use.
136-
137137
## Configuration
138138

139139
All of the CLI options can be configured in the `ava` section of your `package.json`. This allows you to modify the default behavior of the `ava` command, so you don't have to repeatedly type the same options on the command prompt.
@@ -146,9 +146,7 @@ All of the CLI options can be configured in the `ava` section of your `package.j
146146
"!**/not-this-file.js"
147147
],
148148
"failFast": true,
149-
"serial": true,
150149
"tap": true,
151-
"verbose": true,
152150
"require": [
153151
"babel-core/register"
154152
]
@@ -200,7 +198,7 @@ test(function name(t) {
200198

201199
### Assertion plan
202200

203-
An assertion plan can be used to ensure a specific number of assertions are made. In the most common scenario, it validates that the test didn't exit before executing the expected number of assertions. It also fails the test if too many assertions are executed, which can be useful if you have assertions inside callbacks or loops.
201+
An assertion plan can be used to ensure a specific number of assertions are made. In the most common scenario, it validates that the test didn't exit before executing the expected number of assertions. It also fails the test if too many assertions are executed, which can be useful if you have assertions inside callbacks or loops. Be aware that, unlike node-tap & tape, AVA does *not* auto-end a test when the planned assertion count is reached.
204202

205203
This will result in a passed test:
206204

@@ -214,47 +212,15 @@ test(t => {
214212
});
215213

216214
test.cb(t => {
217-
setTimeout(() => {
215+
t.plan(1);
216+
217+
someAsyncFunction(() => {
218218
t.pass();
219219
t.end();
220-
}, 100);
221-
});
222-
```
223-
224-
#### WARNING: Recent breaking change.
225-
226-
AVA no longer supports automatically ending tests via `t.plan(...)`. This helps prevent false positives if you add assertions, but forget to increase your plan count.
227-
228-
```js
229-
// This no longer works
230-
231-
test('auto ending is dangerous', t => {
232-
t.plan(2);
233-
234-
t.pass();
235-
t.pass();
236-
237-
// auto-ending after reaching the planned two assertions will miss this final one
238-
setTimeout(() => t.fail(), 10000);
220+
});
239221
});
240222
```
241223

242-
For this to work, you must now use "callback mode", and explicitly call `t.end()`.
243-
244-
```js
245-
test.cb('explicitly end your tests', t => {
246-
t.plan(2);
247-
248-
t.pass();
249-
t.pass();
250-
251-
setTimeout(() => {
252-
// This failure is now reliably caught.
253-
t.fail();
254-
t.end();
255-
}, 1000);
256-
});
257-
```
258224

259225
### Serial-tests
260226

@@ -737,11 +703,6 @@ AVA, not Ava or ava. Pronounced [`/ˈeɪvə/` ay-və](media/pronunciation.m4a?ra
737703
- [Twitter](https://twitter.com/ava__js)
738704

739705

740-
## Other
741-
742-
- [AVA logo stickers](https://www.stickermule.com/user/1070705604/stickers)
743-
744-
745706
## Related
746707

747708
- [gulp-ava](https://github.com/sindresorhus/gulp-ava) - Run tests with gulp
@@ -750,6 +711,11 @@ AVA, not Ava or ava. Pronounced [`/ˈeɪvə/` ay-və](media/pronunciation.m4a?ra
750711
- [start-ava](https://github.com/start-runner/ava) - Run tests with start
751712

752713

714+
## Links
715+
716+
- [Buy AVA stickers](https://www.stickermule.com/user/1070705604/stickers)
717+
718+
753719
## Team
754720

755721
[![Sindre Sorhus](https://avatars.githubusercontent.com/u/170270?s=130)](http://sindresorhus.com) | [![Vadim Demedes](https://avatars.githubusercontent.com/u/697676?s=130)](https://github.com/vdemedes) | [![James Talmage](https://avatars.githubusercontent.com/u/4082216?s=130)](https://github.com/jamestalmage)

0 commit comments

Comments
 (0)