Hi everyone, is there a way to set Mocha timeout? ...
# javascript
o
Hi everyone, is there a way to set Mocha timeout? The
timeout
parameter only works in node, not in browser
t
browser
target?
o
Yes,
js.browser
in multiplatform setup
I can do
Copy code
browser {
    testTask {
        useMocha {
            timeout = "10s"
        }
    }
}
But this runs the tests in node, and using karma the option doesn't exist. This is doesn't work
Copy code
browser {
    testTask {
        useKarma {
            timeout = "10s"
        }
    }
}
t
Please check WA 1. Create folder
karma.config.d
in subproject 2. Add file
patch.js
in
karma.config.d
3. In
patch.js
you can access
config
var (Karma config) to configure timeout
o
Cool, let me take a look, thanks
karma.config.d
didn't worked, but
webpack.config.d
did, one problem is the
config
variable is not the global one, but one internal inside
createWebpackConfig
So this doesn't work:
Copy code
config.set({
    client: {
        mocha: {
            timeout : 10000
        }
    }
});
TypeError: config.set is not a function
t
config is var
o
Yes, this is the one in scope
t
You need
Copy code
config.client.mocha.timeout = 10000
o
Yes but since the original doesn't define mocha I got an error > TypeError: Cannot read property 'mocha' of undefined
t
config.client.mocha = { timeout: 10000 }
In final variant:
Copy code
config.client = config.client || {}
config.client.mocha = config.client.mocha || {}
config.client.mocha.timeout = 10000
o
Yes, that one works, now I got another weird error, for some reason Webpack doesn't load
I think this config is for webpack, not for karma
but it since it has the same name, I can't access the right one in the outer scope
t
Copy code
if (!!config.client) {
    config.client.mocha = config.client.mocha || {}
    config.client.mocha.timeout = 10000
}
o
Ok, this doesn't fail, but the timeout value is not set correctly (is using the default 2 seconds)
Is working, I made a mistake wth the karma config folder (
karma.conf.d
instead of
karma.config.d
)
Thank you very much
t
I think we need bug report 🙂 youtrack cc @Ilya Goncharov [JB]
s
Is there a ticket about this? Is there a demo repo somewhere? I'm not seeing my
patch.js
getting merged with the generated
karma.conf.js
file.
Fixed,
karma.config.d
folder too high 😅