我有一个crossProject Scala / ScalaJS。在客户端模块中运行测试时,出现以下异常:

IJ]sbt:pme123-adapters-client> testOnly
...
[info] Fast optimizing /Users/pascal.mengelt/GitHub/scala/scala-adapters/client/target/scala-2.12/pme123-adapters-client-test-fastopt.js
[error] [stdin]:10349
[error] })( jQuery, window, document );
[error]     ^
[error] ReferenceError: jQuery is not defined
[error]     at [stdin]:10349:5
[error]     at ContextifyScript.Script.runInThisContext (vm.js:50:33)
[error]     at Object.runInThisContext (vm.js:139:38)
[error]     at Object.<anonymous> ([stdin]-wrapper:6:22)
[error]     at Module._compile (module.js:635:30)
[error]     at evalScript (bootstrap_node.js:462:27)
[error]     at Socket.<anonymous> (bootstrap_node.js:233:15)
[error]     at emitNone (events.js:111:20)
[error]     at Socket.emit (events.js:208:7)
[error]     at endReadableNT (_stream_readable.js:1056:12)
[error]     org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: Node.js exited with code 1


测试在共享模块中运行良好。这是客户端依赖项:

jsDependencies ++= Seq(
      "org.webjars" % "jquery" % jQueryV / "jquery.js" minified "jquery.min.js"
      , "org.webjars" % "Semantic-UI" % semanticV / "semantic.js" minified "semantic.min.js" dependsOn "jquery.js"
    )
libraryDependencies ++= Seq(
    "org.scala-js" %%% "scalajs-dom" % "0.9.3"
    , "org.scala-lang.modules" %% "scala-xml" % "1.0.6"
    , "com.typesafe.play" %%% "play-json" % "2.6.1"
    , "com.thoughtworks.binding" %%% "dom" % bindingV
    , "com.thoughtworks.binding" %%% "futurebinding" % bindingV
    , "fr.hmil" %%% "roshttp" % "2.0.2"
    // java.time support for ScalaJS
    , "org.scala-js" %%% "scalajs-java-time" % "0.2.2"
    // jquery support for ScalaJS
    , "be.doeraene" %%% "scalajs-jquery" % "0.9.1"
    , "org.scalatest" %%% "scalatest" % scalaTestV % Test
  )


是否需要设置sbt?还是我错过了什么。

您在此处找到的整个堆栈跟踪和/或代码:https://travis-ci.org/pme123/scala-adapters/builds/332445805

最佳答案

由于我没有测试,这只是一个解决方法!在某个时候,我想测试我的客户!

我将sbt调用调整为仅测试其他模块:

sbt sharedJVM/test sharedJS/test server/test


.travis.yml示例:

language: scala
script:
  - sbt ++$TRAVIS_SCALA_VERSION clean sharedJVM/test sharedJS/test server/test 'set scalaJSStage in Global := FullOptStage'
scala:
   - 2.12.4
jdk:
  - oraclejdk8

关于jquery - ScalaJS/ScalaTest:ReferenceError:jQuery未定义,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48395676/

10-09 14:39