jsBrowserTest for a multiplatform library

I have a 1.4.10 multiplatform library, targeting for now js(LEGACY) and jvm, with a rather standard build script using the kotlin DSL. Since it’s a library, I don’t have any main() function.

I have some questions about the jsBrowserTest task:

  1. Where is it originally defined? Grepping the whole kotlin and gradle sources didn’t help. I saw some references to metacity in the gradle debug logs.
  2. I understand it is launching a (potentially headless) browser, chosen in the js karma (I’ve read somewhere that it’s best to use a chrome family browser for js maps to properly work). But on which address? If I were to inspect the http traffic with a tool like wireshark or tcpdump, which localhost port should I watch?
  3. If I have a resource located in src/commonTest/resources, it’s visible in the classpath for the jvmTest task ; but how to get hold of it for the jsBrowserTest? I guess it would involve some ajax call, but towards which URI? Does it involve something like a tests webpack or so?
  4. Is remote debugging supposed to work with latest versions of Intellij Idea? Using chromium, the debugger seems to hang when running jsBrowserTest. Can it be so because on my ubuntu, chromium is installed by snap?

Thanks.

Kinda responding to myself.

  1. The jsBrowserTask is defined in the kotlin multiplatform plugin.

  2. It runs a nodejs HTTP server on the port 9876. The browser is opened on an URL like GET /?id=34002427, which then loads /socket.io/socket.io.js, then /absolute/path/to/project/build/js/node_modules/mocha/mocha.js?..., then /context..html, /context.js, some other mocha resources, and then everything happens within websocket connections. On the server side, I see several references in the log: metacity, several npm packages, …

  3. I guess there is a way of having some kind of expect/actual getResource function, that would hit the classpath under the jvm, and use the ktor client -for instance- to fetch the resource using an /absolute/ URL (parametrized or deduced in some way…). Right now, I just turn on an external basic HTTP server on my build/processedResources/js/test/ directory.

  4. I don’t know yet about this one. But it seems like js tooling has a foot in the jvm island and another one in the nodejs one. I’m pretty sure there would be a way to make everyone happy, by having a pure jvm tooling on the server for browser tests.