Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Document how to title macros when using TypeScript
  • Loading branch information
mightyiam authored and novemberborn committed Oct 29, 2017
1 parent b3c4090 commit f98a881
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/recipes/typescript.md
Expand Up @@ -50,6 +50,23 @@ test(async (t) => {
});
```

## Working with [macros](https://github.com/avajs/ava#test-macros)

In order to be able to assign the `title` property to a macro:

```ts
import test, { AssertContext, Macro } from 'ava';

const macro: Macro<AssertContext> = (t, input, expected) => {
t.is(eval(input), expected);
}

macro.title = (providedTitle, input, expected) => `${providedTitle} ${input} = ${expected}`.trim();

test(macro, '2 + 2', 4);
test(macro, '2 * 3', 6);
test('providedTitle', macro, '3 * 3', 9);
```

## Working with [`context`](https://github.com/avajs/ava#test-context)

Expand Down

0 comments on commit f98a881

Please sign in to comment.