Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Dec 08 21:05
    rgroothuijsen synchronize #4068
  • Dec 08 13:47
    eemeli opened #4123
  • Dec 06 17:35
    Jack-Barry opened #4122
  • Dec 06 11:09
    mantoni opened #4121
  • Dec 05 20:53
    carolstran labeled #4120
  • Dec 05 20:53
    carolstran opened #4120
  • Dec 05 17:05
    stale[bot] closed #4098
  • Dec 05 11:07
    New Donation: CodeFund gave USD 6.91 to MochaJS! [Thank that person on Twitter]
  • Dec 05 09:19
    giltayar synchronize #4038
  • Dec 05 08:31
    giltayar synchronize #4038
  • Dec 05 08:09
    giltayar synchronize #4038
  • Dec 04 18:44
    JosejeSinohui synchronize #4112
  • Dec 04 18:08
    TheRoSS opened #4119
  • Dec 04 18:08
    TheRoSS labeled #4119
  • Dec 04 17:52
    kylef opened #4118
  • Dec 04 15:53
    giltayar synchronize #4038
  • Dec 04 15:04
    giltayar synchronize #4038
  • Dec 04 14:50
    giltayar synchronize #4038
  • Dec 04 14:41
    giltayar synchronize #4038
  • Dec 04 14:31
    giltayar synchronize #4038

Hey guys!
In Chrome 76 they disabled 'disable-infobars' flag.
I found and replacement for this,


...but can't get how can I pass this in chrome args. Can anybody advise?

Lars Willighagen
I'm getting the error "--reporter <reporter>" can only be specified once, did that change somewhat recently (say 6.0.0)?
it did, forget to check git blame
Muhammad Haj Yahya
Hello guys, I wanted to integrate mocha unit testing with my project, when I run ">mocha test --reporter mochawesome" I get unknown reporter mochawesome
I am able to run mochawesome programmatically but I would like to run it from the cmd
any one have any clue to solve this issue ?
Craig Taub
@mhmdmar with latest v6.2.0 I did below
  1. Using fresh babel example (https://github.com/mochajs/mocha-examples/tree/master/babel)
  2. npm i mochawesome
  3. mocha --reporter mochawesome
    works for me. Perhaps something with ur configuration.
//why my 2nd test fails? any suggestions?


function calculateSquare(number, callback) {
  setTimeout(() => {
    if (typeof number !== 'number') {
     callback('Argument of type number is expected');
    const result = number * number;
    callback(null, result);
  }, 1000);

module.exports = calculateSquare;


const calculateSquare = require('../calculate.js');
const expect = require('chai').expect;

describe('calculateSquare', function () {
  it('should return 4 if passed 2', function (done) {
    calculateSquare(2, function (error, result) {
      console.log('callback got called');
      done(); // call this when Async! 

  it('it should return an error if passed a string', function (done) {
    calculateSquare('string', function (error, result) {
      expect(error.message).to.equal('Argument of type number is expected');
callback got called
    ✓ should return 4 if passed 2 (1008ms)
    1) it should return an error if passed a string

  1 passing (2s)
  1 failing

  1) calculateSquare
       it should return an error if passed a string:

      Uncaught AssertionError: expected null to not equal null
      + expected - actual

      at /Users/nadia/test/calculate.test.js:15:28
      at Timeout.setTimeout [as _onTimeout] (calculate.js:8:5)

npm ERR! Test failed.  See above for more details.
Craig Taub
@nadiaschutz error is not an object, you have passed a string.
Change callback('Argument of type number is expected’); to callback(new Error('Argument of type number is expected'));.
Or assert on error as a string.
@craigtaub good catch! thanks!
Craig Taub
no worries
shemar dacosta
I've been having trouble with using mocha with spectron and babel
Babel isn't transpiling my components. my test script goes
"test": "mocha --require babel-core/register"
My .babelrc
    "presets": [
        "env",{"targets": {"node": "current"}}
Tejas Deshpande
I am looking to click through a dynamic list of links on a page and show those in the "describe" or "it" titles. Can anyone please suggest how this can be done?
Javier Pons
I'm looking to how I can get the code that write passing or failing on my test. The reason is that I want to save that result in db/show it in my Frontend.
Javier Pons
const assert = require("chai").assert;
const sayHello = require("../app").sayHello;
const addNum = require("../app").addNum;

//const app = require("../app");

describe("App", function() {
  it("app should return hello", function() {
    assert.equal(sayHello(), "hello");
  it("app it should be a string", function() {
    assert.typeOf(sayHello(), "string");
  it("should return 15", function() {
    assert.equal(addNum(8), "15");
  it("should be a number", function() {
    assert.typeOf(addNum(5), "number");
So that when Im getting the results on this simples tests and getting x passing y failing. How I can access to passing/failing text for use it as I want.
Peter Müller
@JavierPons Switch to a different reporter with structured data. The TAP reporter or the JSON reporter might be good bets
Javier Pons
@Munter Good shoot. Get it.
Peter Müller
Javier Pons
@Munter Thanks
Martin Quito
Hi! I'm new to Gitter. I'm trying to have mocha watch my source/project files and NOT the test files. how can I accomplish this? Also the test files and source/project files are in different directories. Thank you in advance!
Javier Pons
Im running
 const mocha = new Mocha({
            reporter: "json"
          const pathFile = `./test/${title}`;


          const runner = mocha.run(failures => {
            if (failures) console.log(true);
in the console I get a bunch of info. I would like to manipulate that info as I want. But when I console log runner the info that I get is very different as the info mocha run and show as default in terminal. I have been looking for info on the net with no results. Is it possible to access to ReferenceError an the json file?
Javier Pons
Can I manipulate all the info of running test?
Peter Müller
@JavierPons What are you trying to do?
Javier Pons
@Munter I want to access to the data that I get in terminal. I need info from that after running a test. I want to manipulate/use that info.
Mansi Jain
What could be the reason my mocha tests pass when individual files are run but fail when run concurrently?
@supermansi could you provide more information there could be a ton of reasons for that.
Which tests are failing when you run them together?
Peter Müller
@supermansi sounds like accidental shared state across tests
HI All
Can you let me know how to write unit tests for typescript classes
NGUYEN Chi Thanh
Hi all
can we specify modules path dynamically with mocha?
I have a test.js, and a required module in /my/module/directory/mymodule.js
how would I run test.js with import of mymodule.js? knowing that the directory would change, so I'll need to specify the directory in mocha comnand line
is that possible to do so? something like "mocha --module-path=/my/module/directory test.js"
Peter Müller
@ctnguyen why does a normal node require not work for you?
@nriesco you set up typescript compiling yourself, then you make you're tests like you normally would in mocha
NGUYEN Chi Thanh
@Munter because mine is not a standalone javascript project. I build js from webassembley, those js file are built and stored in the build directory. The test.js are stored in the source code directory. I need a way to tell test.js where to find my compiled asm.js
Peter Müller
@ctnguyen so you can't just require your build artefact?
NGUYEN Chi Thanh
@Munter I guess I'll need to give the path to tell mocha where it is?
Peter Müller
@ctnguyen No. You require in your build artifact, which is hopefully a node compatible module. Just do that in your test, just like when you test any other module
NGUYEN Chi Thanh
oh thanks @Munter . I'll try it now
Vishal Biradar
What is the formula, used by mocha to calculate the code coverage