Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Apr 24 2020 17:07
    nicojs synchronize #4234
  • Apr 24 2020 16:55
    juergba unlabeled #4251
  • Apr 24 2020 15:47
    Daniel0113 edited #4219
  • Apr 24 2020 15:45
    Daniel0113 edited #4219
  • Apr 24 2020 15:11
    Daniel0113 synchronize #4219
  • Apr 24 2020 14:01
    juergba labeled #4227
  • Apr 24 2020 14:01
    juergba unlabeled #4227
  • Apr 24 2020 14:01
    juergba unlabeled #4227
  • Apr 24 2020 13:58
    juergba edited #4251
  • Apr 24 2020 13:33
    juergba labeled #4251
  • Apr 24 2020 12:52
    juergba milestoned #4251
  • Apr 24 2020 12:52
    juergba labeled #4251
  • Apr 24 2020 12:52
    juergba labeled #4251
  • Apr 24 2020 12:52
    juergba labeled #4251
  • Apr 24 2020 12:51
    juergba assigned #4251
  • Apr 24 2020 12:51
    juergba review_requested #4251
  • Apr 24 2020 12:51
    juergba opened #4251
  • Apr 24 2020 12:37

    juergba on karma

    type check before calling retri… (compare)

  • Apr 24 2020 06:26
    juergba labeled #4250
  • Apr 24 2020 06:26
    juergba labeled #4250
how can i get the total time of a given describe block? if i leave set-up code in an it, the time is shown (using the spec reporter of course): ✓ returns an array of numbers (292ms). but if i move the set-up code to a before block, the reporter doesn't report anything about the total time so it looks like i've sped up the tests even tho I didn't speed it up. I just hid parts of the test somewhere else.
Sebastianus Sembara

i got error
GET /:id
should return a book if valid id is passed:
Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (C:\laragon\www\user-rest-api\test\book.test.js)

any sugestion

is it possible to change the font color w/o modifying the repo config?
ie is there a global override config so I don't have to commit changes specific to my workflow/env?
Khairi Husseini
hello everyone. I am facing a weird problem with promises inside mocha. For some reason my async function always returns a promise even when using .then(data => data). can anyone help out?
Khairi Husseini
ah with async/await it works fine
William Entriken
Hi Room. Happy Sunday Hackday
so what's the deal, no way to override mocha color defaults?
will I have to alter my color scheme?
or (god forbid) configure it manually in every project, forcing my workflow specifics on everybody else?
Smart QA Lead

HI Pals,

I am looking for implementing distributed execution for our mocha test automation framework.
Currently we have Mocha-Parallel + NodeJs + Selenium + Jenkins in our framework. And Im planning for execution of tests by splitting into multiple tests and each running in parallel in multiple jenkins salve nodes in parallel [the test should be split automatically - like its handled in mocha-parallel] and only one report should be produced for a build.

ex. 1 build in jenkins -> 50 suites -> automatically split them equally and run in 3 salves with 4 parallel threads in each salves -> once all tests are executed only one combined mochawesome report should be generated -----> is this possible ?

Would be extremely grateful, if someone could help me out here.


Sebastian T F
Is it still the case that we cant set env vars using mocha config files? If yes, why is it like that? Wouldn't that be a useful feature to allow setting some env vars for all mocha test using config files?
1 reply
Oleksandr Tsymbaliuk

hi all, hope someone met it before
I am observing strange behavior when I am using "grep" function.
mostly the problem is in this method:
var match = self._grep.test(test.fullTitle());
(node_modules\mocha\lib\runner.js )

from time to time also here (where _grep.test is using):

Runner.prototype.grep = function(re, invert) {
  debug('grep(): setting to %s', re);
  this._grep = re;
  this._invert = invert;
  this.total = this.grepTotal(this.suite);
  return this;

The problem that method var match = self._grep.test(test.fullTitle()); outputs false, while it should be true, but only for some 'it' (tests). My describe has 2 it, one is passed, the other not visible because of condition 'false'
At the same time, this method Runner.prototype.grep is showing 2 'it', but this thing self._grep.test(test.fullTitle()) is validating only one. In some cases both of methods skips some 'it'.
this one 'it' not visible:
this is some description @testing @testing-smoke Ensure dashFeeSensitivity exist
while next 'it' works:
'this is some description @testing @testing-smoke Ensure dashMaxFloor exist'

bot of them should return 'true'

/@testing |@testing$|@testing-smoke |@testing-smoke$/g.test('this is some description @testing @testing-smoke Ensure dashFeeSensitivity exist')
/@testing |@testing$|@testing-smoke |@testing-smoke$/g.test('this is some description @testing @testing-smoke Ensure dashMaxFloor exist')

Any help is very appreciate !

Hi everyone,
Added reset() in config, beforeTest.
But this results in, resetting twice for the first test, in each spec. As for each new spec, wdio creates a new session and the app gets reset.
Is there a way, may be in beforeTest hook, to avoid reset() the app for the first test in the spec file as it will be done anyway as its new spec file and a new session is created?
Hi all. I understand how I can skip a test with (condition ? it : it.skip) Now what I want to do. I can add a bolean to the code to be false and put that in the condition so it skips. Now I try to set the boolean in the before and then it doesn't work. I know the boolean changes in the before, but it doesn't run the test. Can you do something like this, so set a variable in the before to run the test? Example, I set the boolean with true if an element extists. A first it expects this boolean to be true (works). A second it should do something with the content. But if the element is not there there is no need to try the test, hence the skip.
Juerg B.
Mocha runs in cycles, see RUN CYCLEs, especially item 8.
When describe() runs, the test runner will be built, but no hooks or tests are executed, yet. So setting your boolean in a hook, will not work. It's too late.
There is the dynamic this.skip() you can use for that.
Thanks, I just did that for these types of boolean checks. I add an if (condition) this.skip() to the test where needed
Bryce Carr

Hey friends, is there a way to stop a suite mid-execution while allowing after() hooks to run? I've got a long-running suite that does cleanup at the end, and often I'll identify an issue early on and want to restart the suite. My options are to let it finish and do the cleanup properly, or kill the script and clean things up myself.

I tried setting a breakpoint inside an it() and entering this.test.parent.pending = true in the debugger console, but this seemed to skip the after hook.

2 replies
Hi all. Has anyone upgraded mocha to v9 while continuing to use the esm package?
2 replies
Smart QA Lead
Hi folks,
Im using Mocha for our Selenium automation. Post Jenkins setup (enabling .net) in my Windows machine, im facing this issue. I cant use npm, yarn or any other package i used earlier.
I made no changes to npm setup. Just installed jenkins slave service via winsw.exe and its working fine. Post this setup, my mocha is making trouble. Im struck here. Can someone rescue me ?
Smart QA Lead
this cmd worked fine earlier -> yarn run parallel tests/....js , but now it says (jenkins log)
  • APP_URL=https://some.url.com/
  • HEADLESS=false
  • yarn run parallel tests/dir/sometest.js --retries 2 --reporter mochawesome --reporter-options reportFilename=amochawesome_14_Aug_2021_04_00_37_CUT,charts=true,enableCode=false
    C:/qa/workspace/DIR@tmp/durable-7e5c293d/script.sh: line 168: yarn: command not found
I just realized a specific problem for me
Basically, --watch watches all files, and I'm writing a test that modifies the files
so it runs recursievly
My bad, I had to type [\".json\"] instead of .json
Igor Rubis
Hi all.
Can anyone please help me with handling assertion errors in mocha?
I want to use try-catch on a block of code. After an error is caught I want to do some logging and then throw it to fail the test.
Igor Rubis
The issue is that test fails without visiting the catch block.
Moriz Büsing

hi everyone! i just tried upgrading to 9.0.3 and i'm getting a TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts". Running (obviously) on typescript, with the command
TS_NODE_PROJECT='./tsconfig.test.json' mocha -r ts-node/register -r tsconfig-paths/register 'src/**/*.test.ts'.
this is my tsconfig.test.json:

  "compilerOptions": {
    "moduleResolution": "node",
    "target": "es5",
    "module": "commonjs",
    "lib": ["es2015", "es2016", "es2017", "esnext", "dom"],
    "strict": true,
    "sourceMap": true,
    "declaration": false,
    "strictNullChecks": false,
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": false,
    "resolveJsonModule": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "esModuleInterop": true,
    "baseUrl": "src",
    "paths": {
      "@pages/*": ["pages/*"],
      "@components/*": ["components/*"],
    "typeRoots": ["node_modules/@types"]
  "include": ["src"]

any ideas?

Hello here, one question: is there a way to avoid this kind of error messages?
Error: Timeout of 60000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
@igor-rubis I use chai
@jimmybirrias we need to see what that function looks like
@nopeless my test function is a empty test
it("empty function", function(done) {
Konstantin Bläsi
@jimmybirrias you need to either add done();to the body or make the test function an async funtction
yes, I have noticed it but is there way to avoid the timeout error?
Konstantin Bläsi
it("empty function", async function() {
this would also work
@jimmybirrias have you tried without the done parameter? Maybe mocha is smart enough to not expect done to be called then
otherwise I assume no, personally I would just do either of the two above
mocha just assumes the test is not done until this callback named done here is called
Konstantin Bläsi
If your test is completely synchronous you'd not need a done callback or async function technically, but node / javascript code is very async in nature so you'll probably want it in most cases
Pavlína Wurzel Gonçalves

Hi! I am in a research team doing a study about what skills are needed for efficient code reviews and how to help developers improve their personal code review practice. We would be very grateful if you would consider participating in the study!


Pavlina, Gul, Alexander and Alberto
University of Zurich, Eindhoven University of Technology

Smart QA Lead
Mocha merge shows incorrect Duration and Suites - post merging multiple json files -> Antontelesh/mochawesome-merge#71
is anyone facing similar issue ?
Konstantin Kostiuk
is it possible to suppress the output of test failure details?
3 replies
Julian Gonggrijp
Hey folks I see I can skip a test dynamically by calling this.skip(). I would like to do something similar, but marking the test as successful instead. Is there a way to do that? I couldn't find the class or object that has the skip method in the API documentation.
2 replies
Vlad Danilov
Hi all,
In the file I have before() after() describe and it. I would like to run only one it, I know about .only, but I always should comment before and after. Is there a way how can I run only one it without commenting before and after? Thank you in advance.
1 reply
2 replies