Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 13:33
    stale[bot] closed #3948
  • 10:35
    New Donation: VPN Black Friday gave USD 80 to MochaJS!
  • 10:27
    ericzered edited #4094
  • 10:26
    ericzered labeled #4094
  • 10:26
    ericzered opened #4094
  • Nov 13 09:59
    wll8 labeled #4093
  • Nov 13 09:59
    wll8 opened #4093
  • Nov 13 04:40
    pzrq opened #4092
  • Nov 11 14:51
    New Donation: CodeFund gave USD 6.91 to MochaJS! [Thank that person on Twitter]
  • Nov 11 13:31
    juergba labeled #4091
  • Nov 11 13:31
    juergba unlabeled #4091
  • Nov 11 11:09
    basickarl edited #4091
  • Nov 11 11:02
    basickarl edited #4091
  • Nov 11 10:59
    basickarl labeled #4091
  • Nov 11 10:59
    basickarl opened #4091
  • Nov 11 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
Suresh Salloju
@sallojusuresh
i will try
Vishal Biradar
@vishalbiradar
@Munter yes, I got it. how nyc framework is calculating the code coverage percentage.
Mason Rhodes
@solaris765

I'm having an issue where mocha --watch is only loading changes to the actual *.test.js files in my test folder, but not the supporting files in my src. After searching a bit I'm lead to believe this is due to require caching my src. Is this expected behaviour? And how do I best work around it / the correct way to watch files.

Thanks

Juerg B.
@juergba
@solaris765 we have refactored our --watch feature just a few days ago. It will be published with release v7 (no date available) or you can download our master branch to use it. With a new option --watch-files you determine the files to be watched.
Mason Rhodes
@solaris765
oh, well how about that. I'll give that a shot. Thanks
Mason Rhodes
@solaris765

Hmm, with the new change I'm still getting the same issue.
This is the command I'm using
./node_modules/.bin/mocha --watch-files test,src --watch --recursive

'test' and 'src' are directories in the package root.
changes made in 'test' are picked up, changes made in 'src' do trigger a test re-run but the changes are not present

Juerg B.
@juergba
@solaris765 we will have a look ... thanks.
Michael Fan
@michaelyfan
How does one call describe asynchronously?
I'm not talking about asynchronous calls inside describe, I'm talking about describe inside an asynchronous call (for example in a Promise .then block)
raghanag
@raghanag
hi has anyone used karma runner with typescript here
i am getting a ERROR [karma-server]: UncaughtException
with no details at all
Thomas Scholtes
@geigerzaehler
@solaris765 I had a look at you issue with file watching and it works for me. I have a test/main.js file that requires src/index.js. If I modify src/index.js these changes are reflected in the subsequent test run triggered by the watcher. Would you mind opening an issue on Github so we can investigate this further?
Juerg B.
@juergba
@geigerzaehler a simple test case could be: watch Mocha'slib/runner.js and apply changes to it. Tests are rerun, but the changes in lib/runner.js are not active.
Thomas Scholtes
@geigerzaehler
@juergba Tested this and it works.
Juerg B.
@juergba
@geigerzaehler In my case it only works when I add var Runner = require('./mocha/lib/runner.js'); to my Mocha test file. Without this additional (unnecessary) require the changes to lib/runner.js are not reflected.
Thomas Scholtes
@geigerzaehler
@juergba: I created this issue: mochajs/mocha#4016.
It is a very narrow case that has a workaround and was an issue before. It’s quite hard to fix properly
Juerg B.
@juergba
@geigerzaehler thanks
@solaris765 could you add your case to this issue, please?
Mason Rhodes
@solaris765
@juergba @geigerzaehler I've added my specific case to 4016. And thanks for the work around for now. As far as I can tell, for now anyways, --recursive may be better left to final testing before deployments as opposed to a during development tool with the watcher at least.
kundol
@wnghdcjfe
Hi
raghanag
@raghanag
Hi All
how to specify a js file which loads the all the libs using requirejs with ts-mocha option
Craig Taub
@craigtaub

@raghanag ts-mocha is a wrapper over mocha so not sure if completely follow that part. if its a TS issue we have an example TS mocha here https://github.com/mochajs/mocha-examples/tree/master/typescript.

The other part of ur question, u can create a load-libs.js file which requires all your libs and use mocha —require load-libs.js to load them before tests.
Does this help? if not pls supply more details about problem.

raghanag
@raghanag
@craigtaub thanks
raghanag
@raghanag
can you give me a sample of the load-libs.js file
raghanag
@raghanag
can i use .mocharc.json to load all the libs required by my spec files to load
Craig Taub
@craigtaub

@raghanag you can use .mocharc.json to load a single file which itself requires all other libs.
load-libs.js

require("@babel/register”);
require(“some-other-lib”);

does that help?

Beka Iglesias
@geekshabeka_twitter
Hello! I am using mocha + chai to wirte unit tests for my node Rest API
I need to launch node server.js with two parameters
my tests are failing to launch because of they are missing the parameters
how can I say to mocha + chai that launch app with parameters when I do npm test as it do when I do npm start?
I use mocha before but it's the first time that I need to indicate parameters because in this case part of the endpoints are a wrapper for another java server
Craig Taub
@craigtaub
@geekshabeka_twitter if mocha is launching the app, you can pass params to mocha like env KEY=MINE mocha and use process.env.KEY from inside your test code. Hope that helps
Beka Iglesias
@geekshabeka_twitter
Thanks for the answer.I will try it
Veera Subba Reddy
@subbulomada_twitter
Hi All, Can some help on the below issue. I am seeing TypeError: $(..).waitForExist
setValue is not a function.
I am using JavaScript with mocha framework
Jacob Bogers
@Jacob_Bogers_twitter
hi
is setup(...)function part of the mocha test library, I am looking at some code 4yo, and It seems this is part of mocha?
Peter Müller
@Munter
@Jacob_Bogers_twitter It's part of the TDD interface. https://mochajs.org/#tdd
Jacob Bogers
@Jacob_Bogers_twitter
Hi @Munter thanks for answering, just figured it out
my real problem was the my IDE (vscode) was marking "suite" as unknown global, I just had the add { "env":"mocha"} and plugins: ["mocha"] to the eslintrc file
now my IDE isn't screaming anymore
Armin Ayari
@mrastiak
Hello everyone
How can I skip all the remaining test cases in a test suite after one of the test cases fails
Craig Taub
@craigtaub
@mrastiak test cases should really work in isolation and not depend on each others results. So they should be put into the state they require in order to run your tests.
Peter Müller
@Munter
Someone has made a library that gives you this functionality. https://www.npmjs.com/package/mocha-steps
But generally I agree with @craigtaub . Wouldn't recommend using it
Armin Ayari
@mrastiak
@craigtaub Thank you for the fast reply
What I'm testing is the procedure of buying a product and if a step fails the rest of the steps will fail too
Every step here is a test case and creating a test suite for each step with one test case looks like a bad idea to me
Peter Müller
@Munter
You might want to look into other test runners that are purpose-built for this. Like Selenium, Cypress and other browser runners
raghanag
@raghanag
Hi @craigtaub i am using mocha with ts-node to test the spec files written in typescript, i am getting the cannot find module errors when my source file is importing some modules. can you help me here