Closed stefanceriu closed 7 months ago
Okay, so the problem seems to be that the Prefire binary isn't aware of what the right path should be. I've managed to get it working here piggybacking on the config file URL but perhaps you have an idea for a cleaner solution.
We need to reopen this because it still doesn't work for swfit packages e.g. https://github.com/element-hq/compound-ios/pull/61 and neither does my original fix from here so I'm not entirely sure what the problem is.
We were relying on it to set default perceptual precission to 0.98
and I was able to work around it by specifying .snapshot(perceptualPrecision: 0.98)
on the previews themselves.
This might help, the configuration isn't picked up when running directly through xcodebuild
either
xcodebuild -project 'PreFireExample.xcodeproj' -scheme 'PrefireExample' -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' test
I got it working by using URL(filePath:)
to build correct file paths but it's clear that the ConfigPathBuilder
needs tweaking. I would suggest rewriting it to use URls instead of direct string manipulation.
static func load(from configPath: String?, testTargetPath: String?, verbose: Bool) -> Config? {
- let possibleConfigPaths = ConfigPathBuilder.possibleConfigPaths(for: configPath, testTargetPath: testTargetPath)
+ var possibleConfigPaths = [String]()
+
+ if let configPath {
+ possibleConfigPaths = [URL(filePath: configPath).appending(path: ".prefire.yml").path()]
+ }
for path in possibleConfigPaths {
- guard let configUrl = URL(string: Constants.fileMark + path),
- FileManager.default.fileExists(atPath: configUrl.path),
+
+ let configUrl = URL(filePath: path)
+
+ print("🟢 Checking url: \(configUrl)")
+
+ guard FileManager.default.fileExists(atPath: configUrl.path),
let configDataString = try? String(contentsOf: configUrl, encoding: .utf8) else { continue }
if verbose {
🟢 Checking url: file:///Users/stefanceriu/Developer/Prefire/Example/.prefire.yml
🟢 The '.prefire' file is used on the path: /Users/stefanceriu/Developer/Prefire/Example/.prefire.yml
vs what the current version does
🟡 The '.prefire' file was not found by paths:
- /Users/stefanceriu/Developer/Prefire/Example/PrefireExampleTests/.prefire.yml
- Users/stefanceriu/Developer/Prefire/Example/.prefire.yml
- /Users/stefanceriu/Developer/Prefire/Example/Users/stefanceriu/Developer/Prefire/Example/.prefire.yml
Context 🕵️♀️
Setup the Prefire example project to use a
- template_file_path: PreviewTests.stencil
, wherePreviewTests.stencil
is just a copy of the default template next toPreFireExample.xcodeproj
What 🌱
Specifying a
template_file_path
doesn't seem to be working anymore resulting in adoes not exist or is not readable
errorProposal 🎉
Let's try to fix it maybe 😁