BarredEwe / Prefire

🔥 A library based on SwiftUI Preview, for easy generation: Playbook view, Snapshot and Accessibility tests
Apache License 2.0
296 stars 19 forks source link

Can't pass `mainTarget` to `PreviewModels.stencil` #20

Closed markst closed 9 months ago

markst commented 1 year ago

Context 🕵️‍♀️

Inside PreviewModels.stencil we have a conditional import statement:

{% if argument.mainTarget %}
@testable import {{ argument.mainTarget }}
{% endif %}

What 🌱

Where as the PrefireTestsPlugin can be provided with a mainTarget argument. It seems the PrefirePlaybookPlugin has no support for passing the mainTarget?

Proposal 🎉

Think this might be as simple as passing:

"--args",
"mainTarget=\(targetName)",

to the PrefireTestsPlugin.Command

BarredEwe commented 1 year ago

@markst Thank you for the described problem. I'll fix it soon

Foixa commented 1 year ago

When using XCodegen, it lists the targets alphabetically. Stencil uses the first target as mainTarget. I have now fixed this manually. Is there a better solution?

BarredEwe commented 1 year ago

@Foixa I think you can create a .prefire.yml configuration file in the root of the project. Then add the necessary Target to this file.

test_configuration:
  - target: YourTarget 
BarredEwe commented 9 months ago

I added parameter forwarding in the latest release.

test_configuration:
  - imports:
    - UIKit
    - SwiftUI
  - testable_imports:
    - Prefire

prefire_configuration:
  - imports:
    - UIKit
    - Foundation
  - testable_imports:
    - SwiftUI

You can try it 🚀