SNAPSHOT TESTING + Kotlin/JS I love screenshot te...
# kobweb
j
SNAPSHOT TESTING + Kotlin/JS I love screenshot testing UIs. It helps me to confidently change screens and CSS. So I’ve got a work-in-progress library that I’m using for screenshot testing. Here’s what the code looks like:
Copy code
@InterceptTest
  val snapshotTester = SnapshotTester(
    stylesheetsUrls = listOf(
      "<https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300..900;1,300..900&display=swap>",
      "/assets/pico-for-wasmo.css",
      "/assets/Wasmo.css",
    ),
  )

  @Test
  fun enterEmailAddress(
    darkMode: DarkMode,
    frame: Frame = burstValues(...),
  ) = runTest {
    snapshotTester.snapshot(
      frame = frame,
      darkMode = darkMode,
      background = "var(--pico-background-color)",
    ) {
      EnterEmailAddressScreen(
        attrs = {
          classes("FillWidthHeight")
        },
        emailAddress = "",
        emailAddressHelperText = "We'll email you a challenge code",
        canSubmit = true,
        busy = false,
        disabled = false,
        eventListener = {
        },
      )
    }
  }
I’m tempted to do the work to extract the library to be a standalone open source project. Is this useful to anyone? Would you like to beta-test?
👏 2