Skip to content

Commit

Permalink
Merge pull request #11 in ONE/jest-image-snapshot from feature/readme…
Browse files Browse the repository at this point in the history
…-update to master

* commit 'abb4d88157330be376734616a1d4ad57d966a675':
  docs(readme): update for new custom snapshots dir option
  • Loading branch information
anescobar1991 committed Nov 7, 2017
2 parents 26bf361 + abb4d88 commit b16f2b2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Jest matcher that performs image comparisons using [pixelmatch](https://github.c
* `customDiffConfig`: Custom config passed [pixelmatch](https://github.com/mapbox/pixelmatch#pixelmatchimg1-img2-output-width-height-options) (See options section)
* By default we have set the `threshold` to 0.01, you can increase that value by passing a customDiffConfig as demonstrated below.
* Please note the `threshold` set in the `customDiffConfig` is the per pixel sensitivity threshold. For example with a source pixel colour of `#ffffff` (white) and a comparison pixel colour of `#fcfcfc` (really light grey) if you set the threshold to 0 then it would trigger a failure *on that pixel*. However if you were to use say 0.5 then it wouldn't, the colour difference would need to be much more extreme to trigger a failure on that pixel, say `#000000` (black)
* `customSnapshotsDir`: A custom directory to keep this snapshot in
* `customSnapshotsDir`: (default: `__image_snapshots__`) A custom directory to keep this snapshot in
* `customSnapshotIdentifier`: A custom name to give this snapshot. If not provided one is computed automatically
* `noColors`: (default `false`) Removes colouring from console output, useful if storing the results in a file
* `failureThreshold`: (default `0`) Sets the threshold that would trigger a test failure based on the `failureThresholdType` selected. This is different to the `customDiffConfig.threshold` above, that is the per pixel failure threshold, this is the failure threshold for the entire comparison.
Expand Down Expand Up @@ -82,7 +82,7 @@ expect.extend({ toMatchImageSnapshot });
```

## How it works
Given an image (should be either a PNGImage instance or a Buffer instance with PNG data) the `toMatchImageSnapshot()` matcher will create a `__image_snapshots__` directory in the directory the test is in and will store the baseline snapshot image there on the first run.
Given an image (should be either a PNGImage instance or a Buffer instance with PNG data) the `toMatchImageSnapshot()` matcher will create a `__image_snapshots__` directory in the directory the test is in and will store the baseline snapshot image there on the first run. Note that if `customSnapshotsDir` option is given then it will store baseline snapshot there instead.

On subsequent test runs the matcher will compare the image being passed against the stored snapshot.

Expand Down

0 comments on commit b16f2b2

Please sign in to comment.