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):
Given autofailNewSnapshots is true
When no <snapshot_type> snapshot is found
Then the test should fail
Examples:
| snapshot_type |
| text |
| image |
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.
Given autofailNewSnapshots is false
When no <snapshot_type> snapshot is found
And it actual matches the snapshot
Then the test should pass
Examples:
| snapshot_type |
| text | // PASS
| image |
Given autofailNewSnapshots is false
When <snapshot_type> snapshot is found
And it actual matches the snapshot
Then the test should pass
Examples:
| snapshot_type |
| text |
| image |
Given autofailNewSnapshots is false
When no <snapshot_type> snapshot is found
And actual does not match the snapshot
Then the test should fail
Examples:
| snapshot_type |
| text | // PASS
| image |
Given autofailNewSnapshots is false
When <snapshot_type> snapshot is found
And actual does not match the snapshot
Then the test should fail
Examples:
| snapshot_type |
| text |
| image |
Given autofailNewSnapshots is true
When no <snapshot_type> snapshot is found
Then the test should fail
Examples:
| snapshot_type |
| text | // PASS
| image |
Given autofailNewSnapshots is true
When a <snapshot_type> snapshot is found
And actual match the snapshot
Then the test should pass
Examples:
| snapshot_type |
| text | // PASS
| image |
Given autofailNewSnapshots is true
When a <snapshot_type> snapshot is found
And actual does not match the snapshot
Then the test should fail
Examples:
| snapshot_type |
| text | // PASS
| image |
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.