Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 17 21:54
    josh-cain edited #4072
  • Oct 17 21:50
    josh-cain edited #4072
  • Oct 17 08:49
    wnghdcjfe synchronize #4069
  • Oct 16 18:26
    juergba edited #4070
  • Oct 16 17:54
    juergba edited #4070
  • Oct 16 17:30
    juergba synchronize #4070
  • Oct 16 17:30

    juergba on mocha-browser

    browser setup functions adapt existing test (compare)

  • Oct 16 17:06
    New Donation: Yoga Kali gave USD 2 to MochaJS! [Thank that person on Twitter]
  • Oct 16 15:24
    josh-cain labeled #4072
  • Oct 16 15:24
    josh-cain opened #4072
  • Oct 16 12:52
    Stoom closed #4071
  • Oct 16 12:33
    Stoom edited #4071
  • Oct 16 12:31
    Stoom edited #4071
  • Oct 16 12:28
    Stoom edited #4071
  • Oct 16 12:27
    Stoom edited #4071
  • Oct 16 12:26
    Stoom labeled #4071
  • Oct 16 12:26
    Stoom opened #4071
  • Oct 16 12:09
    wnghdcjfe synchronize #4069
  • Oct 16 11:52
    wnghdcjfe synchronize #4069
  • Oct 16 11:45
    wnghdcjfe synchronize #4069
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?
Craig Taub
@craigtaub
we recommend you move to json config (example https://github.com/mochajs/mocha/blob/master/example/config/.mocharc.json). mocha.opts is considered legacy and removed in future versions (so worth updating to new config when you can).
Suresh Salloju
@sallojusuresh
ok
Craig Taub
@craigtaub
if persists pls post before all hook code. error suggests not running async code correctly
Suresh Salloju
@sallojusuresh
before(async function () {
await browserSetup.createBrowser(properties["browserName"]);
});
async createBrowser(browsername = "chrome") {
global.browser = webdriverio.remote({
desiredCapabilities: {
browserName: browsername,
acceptSslCerts: true
},
logLevel: 'verbose',
logOutput: './logs'
});
await browser.init();
await browser.windowHandleMaximize();
}
we are just calling createBrowser in before() method
Craig Taub
@craigtaub
hmm looks ok, possible webdriver issue?
try replacing webdriver parts with basic async to confirm e.g
const createBrowser = async () => Promise.resolve();,
and see if same issue.
Suresh Salloju
@sallojusuresh
@craigtaub thank you
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.