Expand Readme, remove Gleb, up version number

This commit is contained in:
Joshua 2024-04-25 13:01:00 +02:00
parent a12634c9a3
commit 71fe145047
6 changed files with 17 additions and 14 deletions

BIN
.github/assets/Correct.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9 KiB

BIN
.github/assets/Error.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -1,3 +1,4 @@
cypress/
cypress.config.js
.github/workflows/
.github/workflows/
.vscode/

View file

@ -1,2 +0,0 @@
{
}

View file

@ -34,11 +34,9 @@ Alternatively, you can also add `snapshotUpdate` as an Environment Variable to u
Simply pass `--env updateSnapshots=true` when running Cypress.
> If you don't use the default fixture folder, you will also need to add `snapshotPath` to this module's config with the same path you use for `fixtureFolder`.
## Usage
If properly added, usage of this plugin is rather simple, simply add `.snapshot()` to cypress functions that return valid JSON.
If properly added, usage of this plugin is rather simple, just add `.snapshot()` to cypress functions that return valid JSON. (i.e. `cy.wrap`)
### Example
```js
@ -64,16 +62,22 @@ cypress/fixtures/snapshots/my-tests/works/bar.json
```
Snapshots will generally be saved using this convention, provided by Cypress:
Snapshots will generally be saved using this convention, provided by the Cypress Test Steps:
Passing a name to the Snapshot function is required, but not checked, if you want to take multiple snapshots in the same block.
If you have two Snapshots in the same Block, the last one ***WILL*** overwrite the previous one while updating and the then updated Test will fail on the first snapshot.
```
{fixtureFolder}/<Context>-<Describe>-<It>-<Name?>.json
{fixtureFolder}/<Context>/<Describe>/<It>/<Name?>.json
```
If a step wasn't named, it will instead use the `<It>`for the file name, though this means that you will not be able to have more than 1 Snapshot in your It Block, as it would overwrite the previously created Snapshot files.
While running your Tests, if a value changed, it will, of course, no longer match the snapshot and throw an Error.
Which looks like this:
Of course, if a value changed, it will no longer match the snapshot and throw an Error.
![](./.github/assets/Error.png)
When the Test succeeds, it will instead log a Success in the Log and let you know where the File has been saved to, relative to the Fixture Snapshot Folder
![](./.github/assets/Correct.png)

View file

@ -1,8 +1,8 @@
{
"name": "@datashard/snapshot",
"description": "Adds value / object / DOM element snapshot testing support to Cypress test runner",
"version": "2.3.2",
"author": "Joshua <data@shard.wtf>, Gleb Bahmutov <gleb@cypress.io>",
"description": "Adds JSON Snapshot testing support to Cypress",
"version": "3.0.0-beta",
"author": "Joshua <data@shard.wtf>",
"bugs": "https://github.com/datashard/snapshot/issues",
"engines": {
"node": ">=6"
@ -13,13 +13,13 @@
"src/*/**",
"!src/*-spec.js"
],
"homepage": "https://github.com/datashard/snapshot#readme",
"homepage": "https://shard.wtf/snapshot",
"keywords": [
"cypress",
"cypress-io",
"plugin",
"snapshot",
"testing"
"testing", "json"
],
"license": "MIT",
"main": "src/index.js",