From 23c7821213b44e2f85579ea5a244cd4c6ffe35df Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 12 Apr 2021 10:59:35 -0700 Subject: [PATCH] docs: mention 'npm run snap' --- .../docs/api/snapshot-testing/index.md | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/docs/src/content/docs/api/snapshot-testing/index.md b/docs/src/content/docs/api/snapshot-testing/index.md index 557758e07..7c4fadb50 100755 --- a/docs/src/content/docs/api/snapshot-testing/index.md +++ b/docs/src/content/docs/api/snapshot-testing/index.md @@ -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.