Hello :slightly_smiling_face: We’re targeting JS ...
# javascript
o
Hello 🙂 We’re targeting JS and developing a library. We have seen that our jsTest takes 9 min to complete but jvmTest is around 5-6 min. Is there anything we can do to improve performance? We’re using the parallel flag. Follow-up question: what’s the difference between jsTest and jsNodeTest task? Thanks Ola
e
jsTest and jsNodeTest task
IIRC
jsTest
automatically "wraps" tests for Node.js or the browser, depending on what you have activated.
jsNodeTest
is the more fine grained task.
takes 9 min to complete
Given JVM takes 6 minutes, this doesn't look * that * bad. But you might want to first understand which test(s) is taking longer than what you'd expect.
o
Ah thanks for the answer. We have narrowed down the issue to one module. the modules contains most of our tests (don’t ask shy 🙂 ). They seem to run on one thread. Or is the console output misleading me? 🙂
e
What I really meant is, try to identify the single test cases that take too much time
You can quickly check by running those tests from the IDE
o
The issue is, I think, that we have many. The ones that takes most time i 1.5s
From my laptop
e
Ahhh, then I think it might just be the runtime itself that is slow. I don't recall which version of Mocha K/JS is using, but from v8 parallel mode is supported on Node, so there might be a way to do it
10.3.0, so parallel mode should work.
I've looked at the KGP
KotlinMocha
sources, and AFAIU there is no way to specify additional CLI args for Mocha. Looking at https://mochajs.org/#parallel-tests tho, I'm not sure the custom Kotlin
--reporter
supports parallel mode. @Ilya Goncharov [JB] might know more about what the K/JS Mocha test runner supports
i
Mocha can be configured through file, or through
package.json
. I didn’t test with parallel mode, but in limitations I don’t see problems for our reporter https://mochajs.org/#configuring-mocha-nodejs
gratitude thank you 2
e
Looks like the
project.json
way is the quickest way to try it out.
o
Awesome.. thanks!!!
Hm how can I configure it package.json since it’s generated during build time?
e
Inside your Gradle script, this should do the trick
Copy code
compilations.configureEach {
  packageJson {
    customField("mocha", "...")
  }
}
i
Moreover, you can do anything you want in
doLast
of
packageJson
task or
testPackageJson
But for most cases
customField
is enough
o
Thanks 🙂 So something like this?
Copy code
compilations.configureEach{
    packageJson{
        customField("mocha", "parallel:true")

    }
}
e
I think this is what you're looking for
Copy code
customField("mocha", mapOf("parallel" to true))
So that it results in
Copy code
"mocha": {
  "parallel": true
}
Try it out.
o
Will do 🙂 I’m not that familiar how to work with json in kotlin. However, the output seem correct now 🙂
Thanks for the help I managed to decrease the build time from 9 to 6
✔️ 2