Skip to content

Commit

Permalink
Fix base tests running (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahsmartin authored Aug 13, 2024
1 parent b4bd6f6 commit b3f2722
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Sources/SnapshotPreviewsCore/UIKitRenderingStrategy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class UIKitRenderingStrategy: RenderingStrategy {
let windowScene = UIApplication.shared
.connectedScenes
.filter { $0.activationState == .foregroundActive }
.first
.first ?? UIApplication.shared.connectedScenes.first

let window = windowScene != nil ? UIWindow(windowScene: windowScene as! UIWindowScene) : UIWindow()
window.windowLevel = .statusBar + 1
Expand Down
10 changes: 5 additions & 5 deletions Sources/SnapshottingTestsObjc/EMGPreviewBaseTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ @implementation EMGPreview
@end

static NSMutableArray<EMGPreview *> *previews;
static NSArray<NSInvocation *> *cachedInvocations;

@implementation EMGPreviewBaseTest

Expand All @@ -27,9 +26,11 @@ + (instancetype)create {
}

+ (NSArray<NSInvocation *> *)testInvocations {
if (cachedInvocations) {
return cachedInvocations;
}
NSString *className = NSStringFromClass([self class]);
// Only support running this test if it’s a subclass outside of the SnapshottingTests module
if ([className isEqualToString:@"EMGPreviewBaseTest"] || [className hasPrefix:@"SnapshottingTests."]) {
return @[];
}

NSArray<NSString *> *dynamicTestSelectors = [self addMethods];
EMGPreviewBaseTest *testInstance = [self create];
Expand All @@ -41,7 +42,6 @@ + (instancetype)create {
invocation.selector = selector;
[invocations addObject:invocation];
}
cachedInvocations = invocations;
return invocations;
}

Expand Down

0 comments on commit b3f2722

Please sign in to comment.