rensbreur / SwiftTUI

SwiftUI for terminal applications
MIT License
1.21k stars 44 forks source link

Output comparison testing #13

Closed projhect closed 1 year ago

projhect commented 1 year ago

Hello!

I would like to propose that “output comparison” testing (aka snapshot testing) be discussed.

At its minimum, it would only require for write and ioctl functions to be customizable via internal setters or a new Application.init.

Another option would be enabling the injection of a custom Renderer (either using a protocol or subclassing the existing one). Size would need to be customizable too.

@rensbreur have you thought about this already?

rensbreur commented 1 year ago

Hi, I'm open for concrete suggestions. I don't think snapshot testing should be part of SwiftTUI, but if another framework can be supported without requiring big changes in how SwiftTUI works I'd be open to help out.

At its minimum, it would only require for write and ioctl functions to be customizable via internal setters or a new Application.init.

Another option would be enabling the injection of a custom Renderer (either using a protocol or subclassing the existing one). Size would need to be customizable too.

I'm not sure it's that easy to get snapshot tests to work like this, because of things like escape sequences used to redraw specific parts of the screen. Working with layers and controls might be easier but I'm not sure.

rensbreur commented 1 year ago

I'll close this for now until we have more concrete plans.