Permalink
Browse files

Document how to title macros when using TypeScript

  • Loading branch information...
mightyiam authored and novemberborn committed Oct 29, 2017
1 parent b3c4090 commit f98a8810de770c4d22d87302580eecc228c8d052
Showing with 17 additions and 0 deletions.
  1. +17 −0 docs/recipes/typescript.md
View
@@ -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)

0 comments on commit f98a881

Please sign in to comment.