Skip to content

Commit 2d04763

Browse files
gurpreetatwalsindresorhus
authored andcommitted
Add docs for test parameter need to be named t (#1096)
1 parent 59254b7 commit 2d04763

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

docs/common-pitfalls.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ test(async t => {
6363

6464
AVA [can't trace uncaught exceptions](https://github.com/avajs/ava/issues/214) back to the test that triggered them. Callback-taking functions may lead to uncaught exceptions that can then be hard to debug. Consider promisifying and using `async`/`await`, as in the above example. This should allow AVA to catch the exception and attribute it to the correct test.
6565

66+
### Why are the enhanced assertion messages not shown?
67+
68+
Ensure that the first parameter passed into your test is named `t`. This is a requirement of [`power-assert`](https://github.com/power-assert-js/power-assert), the library that provides the enhanced messages.
69+
70+
```js
71+
test(t => {
72+
t.is(1, 1);
73+
});
74+
```
75+
6676
---
6777

6878
Is your problem not listed here? Submit a pull request or comment on [this issue](https://github.com/avajs/ava/issues/404).

readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ AVA tries to run test files with their current working directory set to the dire
251251

252252
### Creating tests
253253

254-
To create a test you call the `test` function you imported from AVA. Provide the optional title and implementation function. The function will be called when your test is run. It's passed an [execution object](#t) as its first argument. By convention this argument is named `t`.
254+
To create a test you call the `test` function you imported from AVA. Provide the optional title and implementation function. The function will be called when your test is run. It's passed an [execution object](#t) as its first argument.
255+
256+
**Note:** In order for the [enhanced assertion messages](#enhanced-assertion-messages) to behave correctly, the first argument **must** be named `t`.
255257

256258
```js
257259
import test from 'ava';

0 commit comments

Comments
 (0)