BarredEwe / Prefire

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

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

Closed markst closed 4 months ago

markst commented 11 months 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 11 months ago

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

Foixa commented 7 months 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 7 months 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 4 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 🚀