Skip to main content

Quick start

Add the plugin to plugins.sbt.

addSbtPlugin("com.siriusxm" % "sbt-snapshot4s" % "0.1.6")

Enable it in build.sbt. See SBT setup for more layouts.

val root = (project in file(".")).enablePlugins(Snapshot4sPlugin)

Add the integration library for your test framework. See supported frameworks for more.

import snapshot4s.BuildInfo.snapshot4sVersion

libraryDependencies += "com.siriusxm" %% "snapshot4s-munit" % snapshot4sVersion % Test

Write a test.

import snapshot4s.munit.SnapshotAssertions
import snapshot4s.generated.snapshotConfig

object MySuite extends munit.FunSuite with SnapshotAssertions {
test("snapshot4s can fill in the blanks") {
val mySnapshotWorkflow = "snapshot4s"
assertInlineSnapshot(mySnapshotWorkflow, ???)
}
test("snapshot4s can update code") {
val mySnapshotCode = List(1, 2, 3)
assertInlineSnapshot(mySnapshotCode, Nil)
}
test("snapshot4s can work with files") {
val mySnapshotWorkflow = "snapshot4s"
assertFileSnapshot(mySnapshotWorkflow, "mySnapshotWorkflow")
}
}

Run test and watch your tests fail. Run snapshot4sPromote and be bedazzled. You should now see:

test("snapshot4s can update code") {
val mySnapshotCode = List(1, 2, 3)
assertInlineSnapshot(mySnapshotCode, List(1, 2, 3)) // <- spot the difference
}

as well as a new mySnapshotWorkflow file.

Run test again and watch them pass.