Added autofailNewSnapshots to force Cypress to fail if no snapshot is found #228
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added autofailNewSnapshots
New parameter "autofailNewSnapshots" default to false.
If true, automatically fail if no existing snapshot found. This is useful for production builds to prevent tests from passing just because they're missing snapshots.
In order to cause a failure when no snapshot is found, both matchImageSnapshot and matchTextSnapshot need to return a result object that has result.passed=false and result.updated=false. That way logMessage throws the Error to make Cypress report the test as a failure.
In order to cause result.passed=false and result.updated=false, we have introduced the new autofailNewSnapshots configuration parameter that does what we want, namely (note the syntax for expressing tests below is Gherkin):
Also, deleted package-lock.json since we now use yarn.
Testing:
The following scenarios test the new functionality pretty well. I tested a few key ones that I cared most about and recorded "// PASS" to indicate that they worked.