Unknown mocha options cause tests to hang
See original GitHub issueI’m trying to run some code before my tests using the mocha require
option, which I thought maybe I could do in the config file as mentioned by https://modern-web.dev/docs/test-runner/test-frameworks/mocha/#configuring-mocha-options.
I’ve found that when I add a require
option, my tests just hang and do not execute, eventually timing out. Similarly, if I add a foo
option, I get the same thing, whereas another known option like ui: 'tdd'
works just fine.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:11 (1 by maintainers)
Top Results From Across the Web
mocha 4 doesn't exit unlike mocha 3 · Issue #3044 - GitHub
I have been running specific set of tests for few years now and have been always upgrading to the latest mocha and everything...
Read more >Mocha - the fun, simple, flexible JavaScript test framework
Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, ... Use .only until you find the test that...
Read more >mochajs/mocha - Gitter
Hello. I am having an issue running tests in a suite based on a variable condition. For example, I have a suite that...
Read more >Mocha tests in node.js hanging or missing - Stack Overflow
The problem I am having is: At the current stage of the program when I run "npm test" I get the tests hanging...
Read more >Unit testing — Vuetify
Because of this, Vue has its own testing utility called vue-test-utils . ... instance and pass an instance to the mount functions options....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@EvgeniyLoginov that’s cool. I added a script after my script with
src="${testFramework}"
, and at that point it’s possible to callbeforeAll
from mocha. I guess either way will work.Oh interesting, I see now why adding
rootHooks
to the config file doesn’t work. The values there are stringified and added to the window (https://github.com/modernweb-dev/web/blob/6c5893cc79c91e82f9aec35d3011c6e33ce878cc/packages/test-runner-core/src/server/plugins/serveTestRunnerHtmlPlugin.ts#L93), so any functions are lost. That’s unfortunate, since I like the idea of specifying the rootHooks in the config file much better than either of our other approaches.In the meantime, I’ve switched to using your approach, since it seems to be more reliable with safari. I now have this in my web-test-runner.config file:
And then in mocha-hooks.js: