Skip to content

Commit a45cdb9

Browse files
committed
Mention magic assert in the readme
And some other tweaks
1 parent c980f97 commit a45cdb9

6 files changed

+23
-11
lines changed

media/magic-assert-combined.png

174 KB
Loading

media/magic-assert-nested.png

40.3 KB
Loading

media/magic-assert-objects.png

43.6 KB
Loading

media/magic-assert-strings.png

29.1 KB
Loading

media/snapshot-testing.png

54.9 KB
Loading

readme.md

+23-11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Follow the [AVA Twitter account](https://twitter.com/ava__js) for updates.
1414

1515
Translations: [Español](https://github.com/avajs/ava-docs/blob/master/es_ES/readme.md), [Français](https://github.com/avajs/ava-docs/blob/master/fr_FR/readme.md), [Italiano](https://github.com/avajs/ava-docs/blob/master/it_IT/readme.md), [日本語](https://github.com/avajs/ava-docs/blob/master/ja_JP/readme.md), [한국어](https://github.com/avajs/ava-docs/blob/master/ko_KR/readme.md), [Português](https://github.com/avajs/ava-docs/blob/master/pt_BR/readme.md), [Русский](https://github.com/avajs/ava-docs/blob/master/ru_RU/readme.md), [简体中文](https://github.com/avajs/ava-docs/blob/master/zh_CN/readme.md)
1616

17+
1718
## Contents
1819

1920
- [Usage](#usage)
@@ -24,6 +25,7 @@ Translations: [Español](https://github.com/avajs/ava-docs/blob/master/es_ES/rea
2425
- [Documentation](#documentation)
2526
- [API](#api)
2627
- [Assertions](#assertions)
28+
- [Snapshot testing](#snapshot-testing)
2729
- [Tips](#tips)
2830
- [FAQ](#faq)
2931
- [Recipes](#recipes)
@@ -32,13 +34,15 @@ Translations: [Español](https://github.com/avajs/ava-docs/blob/master/es_ES/rea
3234
- [Links](#links)
3335
- [Team](#team)
3436

37+
3538
## Why AVA?
3639

3740
- Minimal and fast
3841
- Simple test syntax
3942
- Runs tests concurrently
4043
- Enforces writing atomic tests
4144
- No implicit globals
45+
- [Magic assert](#magic-assert)
4246
- [Isolated environment for each test file](#process-isolation)
4347
- [Write your tests in ES2017](#es2017-support)
4448
- [Promise support](#promise-support)
@@ -47,9 +51,9 @@ Translations: [Español](https://github.com/avajs/ava-docs/blob/master/es_ES/rea
4751
- [Observable support](#observable-support)
4852
- [Enhanced assertion messages](#enhanced-assertion-messages)
4953
- [TAP reporter](#tap-reporter)
50-
- [Clean stack traces](#clean-stack-traces)
5154
- [Automatic migration from other test runners](https://github.com/avajs/ava-codemods#migrating-to-ava)
5255

56+
5357
## Test syntax
5458

5559
```js
@@ -88,7 +92,7 @@ Your `package.json` will then look like this:
8892
"test": "ava"
8993
},
9094
"devDependencies": {
91-
"ava": "^0.17.0"
95+
"ava": "^0.18.0"
9296
}
9397
}
9498
```
@@ -224,11 +228,15 @@ $ ava --tap | tap-nyan
224228

225229
Please note that the TAP reporter is unavailable when using [watch mode](#watch-it).
226230

227-
### Clean stack traces
231+
### Magic assert
232+
233+
AVA adds code excerpts and clean diffs for actual and expected values. If values in the assertion are objects or arrays, only a diff is displayed, to remove the noise and focus on the problem. The diff is syntax-highlighted too! If you are comparing strings, both single and multi line, AVA displays a different kind of output, highlighting the added or missing characters.
228234

229-
AVA automatically removes unrelated lines in stack traces, allowing you to find the source of an error much faster.
235+
![](media/magic-assert-combined.png)
230236

231-
<img src="media/stack-traces.png" width="300">
237+
### Clean stack traces
238+
239+
AVA automatically removes unrelated lines in stack traces, allowing you to find the source of an error much faster, as seen above.
232240

233241

234242
## Configuration
@@ -981,27 +989,31 @@ export default HelloWorld;
981989
import test from 'ava';
982990
import render from 'react-test-renderer';
983991

984-
import HelloWorld from './';
992+
import HelloWorld from '.';
985993

986994
test('HelloWorld component', t => {
987-
const tree = render.create(<HelloWorld />).toJSON();
988-
t.snapshot(tree);
995+
const tree = render.create(<HelloWorld />).toJSON();
996+
t.snapshot(tree);
989997
});
990998
```
991999

9921000
The first time you run this test, a snapshot file will be created in `__snapshots__` folder looking something like this:
9931001

994-
```
1002+
```js
9951003
exports[`HelloWorld component 1`] = `
9961004
<h1>
997-
Hello World...!
1005+
Hello World...!
9981006
</h1>
9991007
`;
10001008
```
10011009

10021010
These snapshots should be committed together with your code so that everyone on the team shares current state of the app.
10031011

1004-
Every time you run this test afterwards, it will check if the component render has changed. If it did, it will fail the test. Then you will have the choice to check your code - and if the change was intentional, you can use the `--update-snapshots` (or `-u`) flag to update the snapshots into their new version.
1012+
Every time you run this test afterwards, it will check if the component render has changed. If it did, it will fail the test.
1013+
1014+
<img src="media/snapshot-testing.png" width="814">
1015+
1016+
Then you will have the choice to check your code - and if the change was intentional, you can use the `--update-snapshots` (or `-u`) flag to update the snapshots into their new version.
10051017

10061018
That might look like this:
10071019

0 commit comments

Comments
 (0)