Skip to content

Commit

Permalink
docs: mention 'npm run snap'
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Apr 12, 2021
1 parent 710951b commit 23c7821
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions docs/src/content/docs/api/snapshot-testing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,33 @@ Asserts: 1 passed, of 1
Time: 422ms
```

By setting `TAP_SNAPSHOT` in the environment, we tell tap to write the
output to a special file, and treat the assertion as automatically
passing.
By setting `TAP_SNAPSHOT` in the environment or passing the `--snapshot`
command line flag, we tell tap to write the output to a special file, and
treat the assertion as automatically passing.

Snapshots will be generated by default if the npm script being run is named
`snap` or `snapshot`, so you can use this pattern to test and snapshot most
projects:

```json
{
"name": "my-project",
"version": "1.2.3",

"devDependencies": {
"tap": "15"
},
"scripts": {
"test": "tap",
"snap": "tap"
}
}
```

Then, you can use `npm test` to run your tests, or `npm run snap` to
update snapshot files.

## Snapshot Files

The [generated file](/snapshot-example/tap-snapshots/test.js-TAP.test.js)
is designed to be human-readable, but you should not edit it directly.
Expand Down

0 comments on commit 23c7821

Please sign in to comment.