Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:51
    New Donation: CodeFund gave USD 6.91 to MochaJS! [Thank that person on Twitter]
  • 13:31
    juergba labeled #4091
  • 13:31
    juergba unlabeled #4091
  • 11:09
    basickarl edited #4091
  • 11:02
    basickarl edited #4091
  • 10:59
    basickarl labeled #4091
  • 10:59
    basickarl opened #4091
  • 07:56
    Alhadis closed #3937
  • Nov 10 19:49
    stale[bot] labeled #3833
  • Nov 09 19:32
    New Donation: Cosmin Olteanu gave USD 5 to MochaJS!
  • Nov 09 07:49
    stale[bot] closed #3973
  • Nov 09 01:00
    MicahZoltu labeled #4090
  • Nov 09 01:00
    MicahZoltu opened #4090
  • Nov 08 10:24

    Munter on npm-funding

    (compare)

  • Nov 07 20:52
    boneskull milestoned #4089
  • Nov 07 20:52
    boneskull labeled #4089
  • Nov 07 20:52
    boneskull labeled #4089
  • Nov 07 20:52

    boneskull on master

    Add funding information to pack… (compare)

  • Nov 07 20:52
    boneskull closed #4089
  • Nov 07 08:51
    Munter review_requested #4089
Javier Pons
@JavierPons
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
@JavierPons
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
@Munter
@JavierPons Switch to a different reporter with structured data. The TAP reporter or the JSON reporter might be good bets
Javier Pons
@JavierPons
@Munter Good shoot. Get it.
Peter Müller
@Munter
Javier Pons
@JavierPons
@Munter Thanks
Martin Quito
@mjquito
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
@JavierPons
Im running
 const mocha = new Mocha({
            reporter: "json"
          });
          const pathFile = `./test/${title}`;

          mocha.addFile(pathFile);

          const runner = mocha.run(failures => {
            console.log(failures);
            if (failures) console.log(true);
          });
console.log(runner);
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
@JavierPons
Can I manipulate all the info of running test?
Peter Müller
@Munter
@JavierPons What are you trying to do?
Javier Pons
@JavierPons
@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
@supermansi
What could be the reason my mocha tests pass when individual files are run but fail when run concurrently?
dhuang612
@dhuang612
@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
@Munter
@supermansi sounds like accidental shared state across tests
raghanag
@raghanag
HI All
Can you let me know how to write unit tests for typescript classes
NGUYEN Chi Thanh
@ctnguyen
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
@Munter
@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
@ctnguyen
@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
@Munter
@ctnguyen so you can't just require your build artefact?
NGUYEN Chi Thanh
@ctnguyen
@Munter I guess I'll need to give the path to tell mocha where it is?
Peter Müller
@Munter
@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
@ctnguyen
oh thanks @Munter . I'll try it now
Vishal Biradar
@vishalbiradar
What is the formula, used by mocha to calculate the code coverage
?
Peter Müller
@Munter
Mocha doesn't calculate code coverage
Vishal Biradar
@vishalbiradar
we use nyc along with mocha to generate the code coverage report
Peter Müller
@Munter
If I've understood nyc correctly, it processes your source code to inject new lines for each statement, which increment some counters. Then if looks at the counters for each line of each file to check coverage. I'm not sure how it handles single line logic branches, like longer boolean expressions etc
Mocha has nothing to do with this. It just runs the javascript provided by nyc
Vishal Biradar
@vishalbiradar
OK
Thanks
Suresh Salloju
@sallojusuresh
Is "async-only" mocha command modified to "asyncOnly"?
Craig Taub
@craigtaub
former for cli usage, latter for use in config
Suresh Salloju
@sallojusuresh
we have created mocha.opt file with --async-only command
it was working fine
but in recentime getting failures at before all hooks

"before all" hook
Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (C:\git\vista\ui\UI_Framework_Hyd\test\specFile\assign_and_unassign_policy_from_group_spec.js)
Peter Müller
@Munter
I recommend switching to the json configuration if you can
Suresh Salloju
@sallojusuresh
any help to resolve above issue
?
This iw my mocha.opt file:
--async-only
-R mochawesome --reporter-options reportFilename=report
--timeout 120000
any help?