Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New canGenerateNewSnapshots to avoid automatically creating missing ones in CI #768

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

NachoSoto
Copy link
Contributor

Fixes #748.

@NachoSoto
Copy link
Contributor Author

NachoSoto commented Dec 19, 2023

Bump?

NachoSoto referenced this pull request Dec 19, 2023
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* fix

* beta 6

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* fix

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* small things

* wip

* DocC + swift-format (#765)

* DocC and swift-format support

* wip

* wip

* wip

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
@CraigSiemens
Copy link

CraigSiemens commented Jan 12, 2024

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 }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Request] Avoid automatically recording snapshots on CI
3 participants