Skip to content

Update for recent tooling versions - Scala 3 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Step 6: Testing
  • Loading branch information
gzm0 authored and OndrejSpanel committed Mar 24, 2024
commit ece173574f17047718e0636e853b9c0da1492572
7 changes: 7 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ scalaVersion := "3.3.3"
scalaJSUseMainModuleInitializer := true

libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "2.8.0"

// Add support for the DOM in `run` and `test`
jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv()

// uTest settings
libraryDependencies += "com.lihaoyi" %%% "utest" % "0.8.2" % "test"
testFrameworks += new TestFramework("utest.runner.Framework")
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")

libraryDependencies += "org.scala-js" %% "scalajs-env-jsdom-nodejs" % "1.1.0"
35 changes: 35 additions & 0 deletions src/test/scala/tutorial/webapp/TutorialTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package tutorial.webapp

import utest._

import scala.scalajs.js

import org.scalajs.dom
import org.scalajs.dom.document
import org.scalajs.dom.ext._

object TutorialTest extends TestSuite {

// Initialize App
TutorialApp.setupUI()

def tests = Tests {
test("HelloWorld") {
assert(document.querySelectorAll("p").count(_.textContent == "Hello World") == 1)
}

test("ButtonClick") {
def messageCount =
document.querySelectorAll("p").count(_.textContent == "You clicked the button!")

val button = document.querySelector("button").asInstanceOf[dom.html.Button]
assert(button != null && button.textContent == "Click me!")
assert(messageCount == 0)

for (c <- 1 to 5) {
button.click()
assert(messageCount == c)
}
}
}
}