Configuring timeouts when running Mocha-based tests in MPP or JS projects

Apparently, when setting up a MPP project to compile over NodeJS, the default option for testing is Mocha. Apparently, Mocha has a 2000ms default timeout which is breaking my tests.

From what I can understand, Mocha can be configured by editing the package.json file generated by Gradle, but I could not find any way to configure the content of the package.json file in my build.gradle.kts.
Am I missing something or it is a missing feature?

1 Like

I have same problem.

Another interesting thing that when I compile my test code to the regular js file and run in browser it took less than 200ms for running. But when I run tests I have an error with 2000ms timeout.

I think I figured this out:

kotlin {
    sourceSets {
    
        // ...

        js {

            nodejs { // or `browser`
                testTask {
                    useMocha {
                        timeout = // mochaTimeout here as string
                    }
                }
            }

            // ...

    }
}

It works! Thank you.