-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix so that tests can be run in parallell with Testing (#12)
* Fix so that tests can be run in parallell with Testing * Fix * Fix * Fix * Rename window * Fix * Add log * Fix * Clean
- Loading branch information
Showing
13 changed files
with
103 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
55 changes: 55 additions & 0 deletions
55
Tests/SnapshotTestCaseTests/TestingSnapshotTestCaseTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import SnapshotTestCase | ||
import SwiftUI | ||
import Testing | ||
|
||
@Suite | ||
class TestingSnapshotTestCaseTests: SnapshotTestCase { | ||
@Test | ||
func test() async throws { | ||
try await verifySnapshot { | ||
TestView() | ||
} | ||
} | ||
|
||
@Test | ||
func test2() async throws { | ||
try await verifySnapshot( | ||
config: SnapshotConfig().add(device: .d6dot1, interfaceStyle: .dark) | ||
) { | ||
let viewController = UIHostingController(rootView: TestView()) | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { | ||
let subRootView = Rectangle() | ||
.foregroundColor(.green) | ||
.clipShape(RoundedRectangle(cornerSize: .init(width: 32, height: 32))) | ||
.edgesIgnoringSafeArea(.all) | ||
guard let subview = UIHostingController(rootView: subRootView).view else { | ||
return | ||
} | ||
viewController.view.addSubview(subview) | ||
subview.frame = viewController.view.bounds | ||
} | ||
return viewController | ||
} | ||
} | ||
} | ||
|
||
private struct TestView: View { | ||
@Environment(\.colorScheme) var colorScheme | ||
|
||
var body: some View { | ||
VStack { | ||
switch colorScheme { | ||
case .light: Text("Light") | ||
case .dark: Text("Dark") | ||
@unknown default: Text("Unknown") | ||
} | ||
|
||
Rectangle() | ||
.foregroundColor(.blue) | ||
.clipShape(RoundedRectangle(cornerSize: .init(width: 32, height: 32))) | ||
|
||
Circle().foregroundColor(.yellow) | ||
} | ||
.edgesIgnoringSafeArea(.all) | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.