Skip to content
Merged
2 changes: 1 addition & 1 deletion Examples/DemoApp/DemoApp/TestViews/ExpandingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ struct ExpandingView: View {
struct ExpandingView_Previews: PreviewProvider {
static var previews: some View {
ExpandingView()
ExpandingView().emergeExpansion(false)
ExpandingView().snapshotExpansion(false)
}
}
2 changes: 1 addition & 1 deletion Examples/DemoApp/DemoApp/TestViews/PreviewVariants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ extension NamedViewModifier {
@available(visionOS, unavailable)
@available(tvOS, unavailable)
static var accessibility: NamedViewModifier {
.init(name: "Accessibility", value: { $0.emergeAccessibility(true) })
.init(name: "Accessibility", value: { $0.snapshotAccessibility(true) })
}

static var rtl: NamedViewModifier {
Expand Down
6 changes: 3 additions & 3 deletions Examples/DemoApp/DemoApp/TestViews/RideShareButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct RideShareButtonView_Previews: PreviewProvider {
// This should never show as a diff
.diffThreshold(1.0)
#if os(iOS)
.emergeRenderingMode(.coreAnimation)
.snapshotRenderingMode(.coreAnimation)
#endif

RideShareButtonView(title: "Request Ride") {
Expand All @@ -55,8 +55,8 @@ struct RideShareButtonView_Previews: PreviewProvider {
.padding()
.previewDisplayName("Ride Share Button View - Light")
#if os(iOS)
.emergeRenderingMode(.coreAnimation)
.emergeAccessibility(true)
.snapshotRenderingMode(.coreAnimation)
.snapshotAccessibility(true)
#endif
}
}
5 changes: 4 additions & 1 deletion Examples/DemoApp/DemoModule/ConversationMessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ struct ConversationCellView_Previews: PreviewProvider {

extension ProcessInfo {
var isPreviews: Bool {
self.environment["EMERGE_IS_RUNNING_FOR_SNAPSHOTS"] == "1" || self.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"
environment["RUNNING_FOR_SNAPSHOTS"] == "1"
|| environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"
// Deprecated alias from the legacy Emerge integration.
|| environment["EMERGE_IS_RUNNING_FOR_SNAPSHOTS"] == "1"
}
}
4 changes: 2 additions & 2 deletions Examples/UnitTestMigration/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Unit Test Migration

This example shows how to migrate from swift-snapshot-testing to preview providers. The example app contains a unit test target `UnitTestMigrationTests` with one [snapshot test](https://github.com/EmergeTools/SnapshotPreviews-iOS/blob/main/Examples/UnitTestMigration/UnitTestMigrationTests/ExampleSnapshotTest.swift). It has been migrated by copying/pasting the file into the main app target as [ExampleSnapshotTest_Migrated.swift](https://github.com/EmergeTools/SnapshotPreviews-iOS/blob/main/Examples/UnitTestMigration/UnitTestMigration/ExampleSnapshotTest_Migrated.swift). The test is modified by removing the XCTest/SnapshotTesting importants, changing the base class to `SnapshotTest` and adding the conformance to `PreviewProvider`.
This example shows how to migrate from swift-snapshot-testing to preview providers. The example app contains a unit test target `UnitTestMigrationTests` with one [snapshot test](https://github.com/EmergeTools/SnapshotPreviews/blob/main/Examples/UnitTestMigration/UnitTestMigrationTests/ExampleSnapshotTest.swift). It has been migrated by copying/pasting the file into the main app target as [ExampleSnapshotTest_Migrated.swift](https://github.com/EmergeTools/SnapshotPreviews/blob/main/Examples/UnitTestMigration/UnitTestMigration/ExampleSnapshotTest_Migrated.swift). The test is modified by removing the XCTest/SnapshotTesting importants, changing the base class to `SnapshotTest` and adding the conformance to `PreviewProvider`.

## Migrating your own tests

1. Add the file [SnapshotTest.swift](https://github.com/EmergeTools/SnapshotPreviews-iOS/blob/main/Examples/UnitTestMigration/UnitTestMigration/SnapshotTest.swift) to your app, this does the heavy lifting of converting snapshot test function calls into previews.
1. Add the file [SnapshotTest.swift](https://github.com/EmergeTools/SnapshotPreviews/blob/main/Examples/UnitTestMigration/UnitTestMigration/SnapshotTest.swift) to your app, this does the heavy lifting of converting snapshot test function calls into previews.
2. Copy your test file from the unit test target to your application.
3. Remove imports of `XCTest` and `SnapshotTesting`.
4. Change the base class from `XCTestCase` to `SnapshotTest` and add a conformce to `PreviewProvider`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
minimizedProjectReferenceProxies = 1;
packageReferences = (
FAB3A5C12C9C705300BF8930 /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */,
FAB3A5C42C9C706100BF8930 /* XCRemoteSwiftPackageReference "SnapshotPreviews-iOS" */,
FAB3A5C42C9C706100BF8930 /* XCRemoteSwiftPackageReference "SnapshotPreviews" */,
);
preferredProjectObjectVersion = 77;
productRefGroup = FA8220082C9C5DB400DA1302 /* Products */;
Expand Down Expand Up @@ -480,9 +480,9 @@
minimumVersion = 1.17.5;
};
};
FAB3A5C42C9C706100BF8930 /* XCRemoteSwiftPackageReference "SnapshotPreviews-iOS" */ = {
FAB3A5C42C9C706100BF8930 /* XCRemoteSwiftPackageReference "SnapshotPreviews" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/EmergeTools/SnapshotPreviews-iOS";
repositoryURL = "https://github.com/EmergeTools/SnapshotPreviews";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.0.0;
Expand All @@ -502,7 +502,7 @@
};
FAB3A5C52C9C706100BF8930 /* PreviewGallery */ = {
isa = XCSwiftPackageProductDependency;
package = FAB3A5C42C9C706100BF8930 /* XCRemoteSwiftPackageReference "SnapshotPreviews-iOS" */;
package = FAB3A5C42C9C706100BF8930 /* XCRemoteSwiftPackageReference "SnapshotPreviews" */;
productName = PreviewGallery;
};
/* End XCSwiftPackageProductDependency section */
Expand Down
Loading
Loading