I am following the Basic Tutorial over at Scala.JS. I've also followed Cannot get uTest to see my tests
I update my build.sbt to have the following:
testFrameworks += new TestFramework("utest.runner.Framework")
libraryDependencies += "com.lihaoyi" %%% "utest" % "0.3.0" % "test"
I have created
src/test/scala/tutorial/webapp/TutorialTest.scala
package tutorial.webapp
import utest._
import org.scalajs.jquery.jQuery
object TutorialTest extends TestSuite {
// Initialize App
TutorialApp.setupUI()
def tests = TestSuite {
'HelloWorld {
assert(jQuery("p:contains('Hello World')").length == 1)
}
}
}
I reload sbt, then type 'test', but I always get the following error:
[error] MyProject/src/main/scala/tutorial/webapp/TutorialTest.scala:3: not found: object utest [error] import utest._
If I remove the tail {% "test"} from my build.sbt, I'm able to run the 'test' command from sbt but it doesn't pick up my tests.
I hope I'm making sense here, this error has stumped me.
The error message shows that you have TutorialTest.scala under
src/main
. It should be undersrc/test
. (Perhaps you accidentally put it in both places?)Test dependencies (such as utest) are only on the classpath when compiling test sources — hence the error.