Closed NachoSoto closed 1 month ago
Bump?
I had a related idea and stumbled across this searching issues for it.
I was looking for a way to record only the snapshots for the failing tests to avoid re-recording all the snapshots in a project. Mainly to avoid unrelated changed being applied and the back and forth of intel/apple silicon shaping out images.
This is just an idea, feel free to take or leave it. We could introduce a recordingMode
rather than having more bools in the tests/globally.
enum RecordingMode {
/// Only record a snapshot when there isn't an existing one. The default behaviour.
case missingSnapshots
/// Record the snapshots only for failing tests. Useful for when a change affects many
/// snapshots across a project but you don't want the snapshots for the passing tests
/// to be recorded as well.
case failingTests
/// Always record snapshots. The same as setting `isRecording` to true.
case always
/// Never record a snapshot. The same as setting `canGenerateNewSnapshots` to true.
case never
}
This could be introduced without being a breaking change by modifying isRecording
to be
public var isRecording: Bool {
get { recordingMode == .always }
set { recordingMode = newValue ? .always : .missingSnapshot }
}
Hi @NachoSoto, thanks for the PR!
It's taken some time, but this is now implemented in #867. I'm going to merge this PR and then it will be updated to mold into what we have going on in #867.
Also, @CraigSiemens, #867 adds your option for recording failed snapshots only (see 0c6b44916f169bf670463133432b7c301da65573). Thanks for the suggestion!
Fixes #748.