passsy / spot

Chainable powerful Flutter widget selector API, screenshots and assertions for awesome widget tests.
https://pub.dev/packages/spot
Apache License 2.0
62 stars 1 forks source link

spot() vs act API #27

Open robiness opened 11 months ago

robiness commented 11 months ago

Not reading any documentation of course and just wanting to kickstart using spot it feels counter intuitive to have spot(), creating an instance of spot and an act, which does not have an constructor. Does it make sense to you to make act() also valid?

I also would love to have an act() method on selectors so this would be interchangeable: await act.tap(spotSingle<ElevatedButton>()); await spotSingle<ElevatedButton>().tap();

Where the latter makes it way more discoverable and , for me at least, more intuitive.

This has probably already been thought of and the act API is about to , since overall the API feels nice and smooth.

passsy commented 11 months ago

Fair request, I thought long about this.

I have the feeling that a .tap() would lead to many mistakes because it returns a Future and has to be awaited. You would most likely miss it every time you use it, right?

passsy commented 8 months ago

Counter argument: "Code is read much more often than it is written, so plan accordingly" src. Thus we should design for readability.

One might argue that a chained tap() might be easier to write.