ScalaJS error - Scala test classes not supported by server

Trying to do a simple scalajs app with scalablytyped. Metals is breaking, defaulting to scala 2 compiler. Finding this in the error logs

Scala test classes not supported by server
INFO  Generated JavaScript file '/Users/john/projects/game/.bloop/game/game-test-js'
INFO  Scala test classes not supported by server
org.eclipse.lsp4j.jsonrpc.ResponseErrorException: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
	...
Caused by: org.scalajs.testing.common.RPCCore$ClosedException: org.scalajs.testing.adapter.JSEnvRPC$RunTerminatedException

I google the error message and find nothing.

Here’s my build.sbt

import org.scalajs.linker.interface.ModuleSplitStyle

lazy val game = project.in(file("."))
  .enablePlugins(ScalaJSPlugin)
  .enablePlugins(ScalablyTypedConverterPlugin)

  .settings(
    name := "okasy2",
    scalaVersion := "3.6.2",
    npmDependencies := Seq(
      "three" -> "0.171.0"
    ),

    Compile / scalaSource := baseDirectory.value / "src/",

    scalacOptions ++= Seq(
      "-language:experimental.namedTuples"
    ),
    scalaJSUseMainModuleInitializer := true,

    scalaJSLinkerConfig ~= {
      _.withModuleKind(ModuleKind.CommonJSModule)
        .withModuleSplitStyle(
          ModuleSplitStyle.SmallModulesFor(List("game")))
    },
    libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "2.8.0",
)

and my project/plugins.sbt

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")
addSbtPlugin("org.scalablytyped.converter" % "sbt-converter" % "1.0.0-beta44")

Everything was working fine until attempting to setup ScalablyTyped.

Do you maybe have a reproduction in a repository? I don’t think we have tests for JS testing in Metals currently so that might not work perfectly.

Or could you post the full stack trace? It looks like the server is failing on testClasses requests and not returning anything for Metals to use, so maybe it’s something we can fix on the server side.

Dear Tomasz:

first at all thanks a lot for your answer and interest. I have created a minimal IntelliJ project with the example code in this folder: scalameter – Google Drive

This is an example taken from the web and the expected graphic generated by the test is also included with the name correct-intervals.png. However when I execute this code I get the result showed in wrong-intervals.png, with the intervals covering all the range of Y axis. And this is the same for all the tests I execute. But the command-line execution shows the following message (I think it is ok):

:::Summary of regression test results - Accepter():::
Test group: Example #1: randArray(5, 0, 1)

  • Example #1: randArray(5, 0, 1).findMissingMutable measurements:
    • at n → 5: passed
      (mean = 0,01 ms, ci = <0,01 ms, 0,02 ms>, significance = 1.0E-10)
  • Example #1: randArray(5, 0, 1).findMissingInPlace measurements:
    • at n → 5: passed
      (mean = 0,04 ms, ci = <0,03 ms, 0,05 ms>, significance = 1.0E-10)
  • Example #1: randArray(5, 0, 1).findMissingSet measurements:
    • at n → 5: passed
      (mean = 0,03 ms, ci = <0,00 ms, 0,06 ms>, significance = 1.0E-10)

Summary: 1 tests passed, 0 tests failed.

Please, let me know if you find a reason for this difference. I greatly appreciate your help in trying to solve this problem. I am working on a research project, and generating these charts would be very helpful to me.

I think you meant to post in Scalameter framework alternatives ?

Yes, sorry for the mistake

I have no tests at all. This is just a scalajs vite template that I added scalablytyped to. It was working a few hours ago.

Changing the folder structure to a multi-project completely broke it.

Any chance you could send us the full stack trace that you are getting?

Directory:

.
├── apps
│   ├── core
│   │   └── src
│   │       └── Color.scala
│   └── web
│       ├── index.html
│       ├── javascript.svg
│       ├── main.js
│       ├── package-lock.json
│       ├── package.json
│       ├── public
│       │   └── vite.svg
│       ├── src
│       │   └── main.scala
│       ├── style.css
│       └── vite.config.js
├── build.sbt
└── project
    ├── build.properties
    ├── metals.sbt
    ├── plugins.sbt
    └── project
        ├── metals.sbt
        └── project
            ├── metals.sbt
            └── project

build.sbt

import org.scalajs.linker.interface.ModuleSplitStyle
import scala.sys.process.Process

lazy val core = project.in(file("apps/core"))
   .settings(
      name := "core",
      scalaVersion := "3.6.2",
      Compile / scalaSource := baseDirectory.value / "src",
      scalacOptions ++= Seq(
         "-language:experimental.namedTuples"
      ),
   )

lazy val web = (project in file("apps/web"))
  .dependsOn(core)
  .enablePlugins(ScalaJSPlugin)
  .enablePlugins(ScalablyTypedConverterExternalNpmPlugin)
  .settings(
    name := "web",
    scalaVersion := "3.6.2",
    Compile / scalaSource := baseDirectory.value / "src",
    scalacOptions ++= Seq(
      "-language:experimental.namedTuples"
    ),
    scalaJSUseMainModuleInitializer := true,
    scalaJSLinkerConfig ~= {
      _.withModuleKind(ModuleKind.ESModule)
        .withModuleSplitStyle(
          ModuleSplitStyle.SmallModulesFor(List("game")))
    },
    libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "2.8.0",
    externalNpm := {
        Process("npm install", baseDirectory.value).!
        baseDirectory.value
      }
    )

vite.config.js

import { defineConfig } from "vite";
import scalaJSPlugin from "@scala-js/vite-plugin-scalajs";

export default defineConfig({
  plugins: [scalaJSPlugin({
     cwd: "../..",
     projectID: "web"
  })
],
});

package.json

{
  "name": "mygame",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  },
  "devDependencies": {
    "@scala-js/vite-plugin-scalajs": "^1.0.0",
    "@types/three": "^0.130.0",
    "three": "^0.130.0",
    "typescript": "^5.7.3",
    "vite": "^4.1.0"
  }
}

metals stack trace

running '/Users/john/Library/Application Support/Coursier/bin/sbt -Dbloop.export-jar-classifiers=sources bloopInstall'
ERROR org.jline.utils.Log logr
ERROR WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
INFO  [info] welcome to sbt 1.10.0 (Homebrew Java 23.0.1)
INFO  [info] loading settings for project practice-build-build-build from metals.sbt ...
INFO  [info] loading project definition from /Users/john/projects/practice/project/project/project
INFO  
INFO    | => practice-build-build-build / Compile / compileIncremental 0s
INFO  [info] loading settings for project practice-build-build from metals.sbt ...
INFO  [info] loading project definition from /Users/john/projects/practice/project/project
INFO  
INFO    | => practice-build-build / updateSbtClassifiers 0s
INFO  [success] Generated .bloop/practice-build-build.json
INFO  
INFO    | => practice-build-build / updateSbtClassifiers 0s
INFO  [success] Total time: 1 s, completed 
INFO  [info] loading settings for project practice-build from metals.sbt,plugins.sbt ...
INFO  [info] loading project definition from /Users/john/projects/practice/project
INFO  
INFO    | => practice-build / updateSbtClassifiers 0s
INFO  [success] Generated .bloop/practice-build.json
INFO  
INFO    | => practice-build / updateSbtClassifiers 0s
INFO  [success] Total time: 1 s, completed 
INFO  [info] loading settings for project practice from build.sbt ...
INFO  [info] set current project to practice (in build file:/Users/john/projects/practice/)
INFO  
INFO    | => web / externalNpm 0s
INFO  [success] Generated .bloop/practice.json
INFO  
INFO    | => web / externalNpm 0s
INFO  [success] Generated .bloop/core.json
INFO  
INFO    | => web / externalNpm 0s
INFO  [success] Generated .bloop/practice-test.json
INFO  
INFO    | => web / externalNpm 0s
INFO  [success] Generated .bloop/core-test.json
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO  up to date, audited 28 packages in 697ms
INFO  
INFO  3 packages are looking for funding
INFO    run `npm fund` for details
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO    | => web / externalNpm 0s
INFO  
INFO  found 0 vulnerabilities
INFO  
INFO    | => web / externalNpm 0s
INFO  [success] Generated .bloop/web.json
INFO  
INFO    | => web / externalNpm 0s
INFO  [success] Generated .bloop/web-test.json
INFO  
INFO    | => web / externalNpm 0s
INFO  [success] Total time: 1 s, completed 
INFO  
INFO  time: ran 'sbt bloopInstall' in 10s
INFO  Attempting to connect to the build server...
INFO  No running Bloop server found, starting one.
INFO  Starting compilation server
INFO  tracing is disabled for protocol BSP, to enable tracing of incoming and outgoing JSON messages create an empty file at /Users/john/projects/practice/.metals/bsp.trace.json or /Users/john/Library/Caches/org.scalameta.metals/bsp.trace.json
INFO  Attempting to connect to the build server...
INFO  Found a Bloop server running
INFO  Attempting to connect to the build server...
INFO  Found a Bloop server running
INFO  tracing is disabled for protocol BSP, to enable tracing of incoming and outgoing JSON messages create an empty file at /Users/john/projects/practice/project/project/.metals/bsp.trace.json or /Users/john/Library/Caches/org.scalameta.metals/bsp.trace.json
INFO  tracing is disabled for protocol BSP, to enable tracing of incoming and outgoing JSON messages create an empty file at /Users/john/projects/practice/project/.metals/bsp.trace.json or /Users/john/Library/Caches/org.scalameta.metals/bsp.trace.json
INFO  time: Connected to build server in 6.53s
INFO  Connected to Build server: Bloop v2.0.6
INFO  running doctor check
INFO  java targets: web-test, core-test, core, practice-build-build, web, practice-build, practice, practice-test
INFO  time: indexed workspace in 1.14s
INFO  compiling core (1 scala source)
INFO  Generated JavaScript file '/Users/john/projects/practice/.bloop/web/web-test-js'
INFO  Scala test classes not supported by server
org.eclipse.lsp4j.jsonrpc.ResponseErrorException: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at bloop.engine.tasks.toolchains.ScalaJsToolchain.discoverTestFrameworks(ScalaJsToolchain.scala:98)
	at bloop.engine.tasks.TestTask$.$anonfun$discoverTestFrameworks$5(TestTask.scala:234)
	at bloop.task.Task.$anonfun$runAsync$7(Task.scala:265)
	at scala.Function1.$anonfun$andThen$1(Function1.scala:57)
	at monix.eval.Task$Map.apply(Task.scala:4604)
	at monix.eval.Task$Map.apply(Task.scala:4600)
	at monix.eval.internal.TaskRunLoop$.startFull(TaskRunLoop.scala:170)
	at monix.eval.internal.TaskRestartCallback.syncOnSuccess(TaskRestartCallback.scala:101)
	at monix.eval.internal.TaskRestartCallback.onSuccess(TaskRestartCallback.scala:74)
	at monix.eval.internal.TaskCreate$CallbackForCreate.run(TaskCreate.scala:252)
	at monix.execution.internal.Trampoline.monix$execution$internal$Trampoline$$immediateLoop(Trampoline.scala:66)
	at monix.execution.internal.Trampoline.startLoop(Trampoline.scala:32)
	at monix.execution.schedulers.TrampolineExecutionContext$JVMOptimalTrampoline.startLoop(TrampolineExecutionContext.scala:132)
	at monix.execution.internal.Trampoline.execute(Trampoline.scala:40)
	at monix.execution.schedulers.TrampolineExecutionContext.execute(TrampolineExecutionContext.scala:57)
	at monix.execution.schedulers.BatchingScheduler.execute(BatchingScheduler.scala:50)
	at monix.execution.schedulers.BatchingScheduler.execute$(BatchingScheduler.scala:47)
	at monix.execution.schedulers.AsyncScheduler.execute(AsyncScheduler.scala:31)
	at monix.eval.internal.TaskCreate$CallbackForCreate.startExecution(TaskCreate.scala:236)
	at monix.eval.internal.TaskCreate$CallbackForCreate.tryOnSuccess(TaskCreate.scala:202)
	at monix.eval.internal.TaskCreate$CallbackForCreate.onSuccess(TaskCreate.scala:195)
	at bloop.task.Task$.result$2(Task.scala:465)
	at bloop.task.Task$.$anonfun$parSequenceUnordered$3(Task.scala:475)
	at bloop.task.Task$.$anonfun$parSequenceUnordered$3$adapted(Task.scala:473)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:74)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1726)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1717)
	at java.base/java.util.concurrent.ForkJoinTask$InterruptibleTask.exec(ForkJoinTask.java:1641)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1458)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2034)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:189)
Caused by: org.scalajs.testing.common.RPCCore$ClosedException: org.scalajs.testing.adapter.JSEnvRPC$RunTerminatedException
	at org.scalajs.testing.common.RPCCore.helpClose(RPCCore.scala:223)
	at org.scalajs.testing.common.RPCCore.close(RPCCore.scala:215)
	at org.scalajs.testing.adapter.JSEnvRPC.close(JSEnvRPC.scala:69)
	at org.scalajs.testing.adapter.JSEnvRPC.$anonfun$new$1(JSEnvRPC.scala:60)
	at org.scalajs.testing.adapter.JSEnvRPC.$anonfun$new$1$adapted(JSEnvRPC.scala:60)
	... 8 more
Caused by: org.scalajs.testing.adapter.JSEnvRPC$RunTerminatedException
	... 10 more
Caused by: org.scalajs.jsenv.ExternalJSRun$NonZeroExitException: exited with code 1
	at org.scalajs.jsenv.ExternalJSRun$$anon$1.run(ExternalJSRun.scala:200)

	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:220)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:204)
	at scala.meta.internal.metals.RequestMonitorImpl$$anon$1.consume(ServerLivenessMonitor.scala:41)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:185)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:97)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:114)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.lang.Thread.run(Thread.java:1575)

INFO  compiling web (1 scala source)
INFO  time: compiled core in 3.36s
INFO  time: compiled web in 0.18s

Raised the issue here Error while fetching testClass in Scala JS project · Issue #2562 · scalacenter/bloop · GitHub

However, that error should still not break your workspace, the only thing that would normally happen is not having test classes discovered for running