Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 18 16:54

    juergba on copy-esm

    remove mocha.runAsync (compare)

  • Feb 17 17:22
    fedulovivan labeled #4186
  • Feb 17 17:22
    fedulovivan opened #4186
  • Feb 17 09:23
    juergba closed #4185
  • Feb 17 09:16
    JavierPons edited #4185
  • Feb 17 09:15
    JavierPons edited #4185
  • Feb 17 08:55

    juergba on copy-esm

    add support for Node.JS native … fix esm test due to node 13 esm… code review adjustments and 1 more (compare)

  • Feb 17 08:42
    JavierPons labeled #4185
  • Feb 17 08:42
    JavierPons opened #4185
  • Feb 16 05:02
    New Donation: LitoMore gave USD 2 to MochaJS!
  • Feb 16 05:02
    New Donation: ProxyCrawl gave USD 2 to MochaJS! [Thank that person on Twitter]
  • Feb 16 04:20
    emma-borhanian closed #4184
  • Feb 16 04:19
    emma-borhanian edited #4184
  • Feb 16 04:18
    emma-borhanian review_requested #4184
  • Feb 16 01:41
    emma-borhanian opened #4184
  • Feb 15 18:28
    prust synchronize #3952
  • Feb 15 14:30
    nicojs edited #4183
  • Feb 14 21:28
    nicojs labeled #4183
  • Feb 14 21:28
    nicojs opened #4183
  • Feb 14 12:58
    rkpareek edited #4182
Adiel Hercules
@adielhercules
Hello! I'm pretty sure not the first to ask about this, but I wanted to know if someone can help me out with this, I have my specs written in es6 but mocha is still not working, I was using v6 of babel but I had to upgrade to v7 and then the issue started, my command is: "mocha --require @babel/register --require @babel/polyfill "./spec/*/.spec.js*" --recursive"
Craig Taub
@craigtaub
@adielhercules are you missing a star before .spec i.e. "./spec/*/*.spec.js*"? I just tried this and worked ok.
We have a live example with mocha v6 + babel v7 here https://github.com/mochajs/mocha-examples/tree/master/babel.
if no luck what are you seeing, an error? no specs run? etc.
Adiel Hercules
@adielhercules
@craigtaub it is very weird but I got it working after I changed the command to just mocha and put all the config of the requires and pattern into a mocha yaml config file. I still dont get why but at least it is working now! Thanks for the help, I based my config from that example.
Craig Taub
@craigtaub
great :)
apert
@apert4160
hello guys , i was wondering domocha enable to comply "list tests without actually executing them" , like a --collect-only option in pytest.Thank you
Craig Taub
@craigtaub
@apert4160 AFAIK that does not exist in mocha, you could write a custom reporter (i.e. https://github.com/mochajs/mocha/wiki/Third-party-reporters) to just print the test name without result, but it would still execute them under-the-hood.
apert
@apert4160
Thanks for your reply
Automation125
@Automation125
hello guys, is there any way to define all hooks/listeners in another file and attach to config file in mocha , which i can do in jasmine
I am using wdio with mocha
Craig Taub
@craigtaub
@Automation125 i believe you can set all hooks inside a file and call it with —file. Example here https://github.com/mochajs/mocha-examples/tree/master/async-setup-with-file
Automation125
@Automation125
@craigtaub is it even possible for wdio, becoz it's not working for me
kiranmai1202
@kiranmai1202
if there is an array[] having elemens as {10.2, 20.5,80.9}
how can we get sum of the array elements which is 10.2+20.5+80.9
ramukarnati
@ramukarnati
hello
if execution is sent to some util function from IT block which handles some common actions -- is there way to handle promises in the util function without being "return" ?
Sampson Crowley
@SampsonCrowley
I'm having issues with the spec report showing tests under the wrong describe block. Anyone have ideas?
CalendarElement (<calendar-element></calendar-element>)
    Attributes
      .labelFormat
        ✔ is EEEE by defaultis is bound to the `label-format` attribute
        when a valid format is entered
          ✔ is reset back to default
        when an invalid format is entered
          ✔ is reset back to default
          ✔ Logs a RangeError
      .headerStyle
        ✔ is an empty string by defaultis is bound to the `header-style` attribute
        ✔ is cooerced to an unvalidated stringis rendered in the section header
      .headerFormat
        ✔ is MMMM yyyy by defaultis is bound to the `header-format` attribute
        when a valid format is entered
          ✔ is reset back to default
        when an invalid format is entered
          ✔ is reset back to default
          ✔ Logs a RangeError
    Events
      date-change
        ✔ is fired when .selectedDate changes
        Properties
          .bubbles
            ✔ is true
          .composed
            ✔ is true
          .cancelable
            ✔ is true
          .detail
            ✔ is an object
            Properties
              value
                when .selectedDate is setis a String
                  ✔ is the current .selectedDate in ISO 8601 format (yyyy-MM-dd)
                when .selectedDate is unset
                  ✔ is null
              date
                when .selectedDate is setis a Date
                  ✔ is the current .selectedDate
                when .selectedDate is unset
                  ✔ is null
// EVERYTHING BELOW IS ACTUALLY IN THE `Attributes` BLOCK
      .selectedDate
        ✔ is empty by defaultis is bound to the `selected-date` attribute
        ✔ is set by clicking a date cell
        when an invalid date is entered
          ✔ sets the value to NULL
          ✔ Logs the invalid date as an Error
      .dayFormat
        ✔ is d by defaultis is bound to the `day-format` attribute
        when a valid format is entered
          ✔ is reset back to default
        when an invalid format is entered
          ✔ is reset back to default
          ✔ Logs a RangeError
Craig Taub
@craigtaub
@ramukarnati using a callback is only other way (i.e. done)
Craig Taub
@craigtaub
@kiranmai1202 not sure thats mocha-related question. try array.reduce((acc, curr) => acc + curr))
Mike Chen
@mike442144
Hey, where can I checkout the break API changes from version 2 to latest?
Paweł Kiełb
@Gieted
This problem is caused by mocha, when I run code directly it works as expected
My .mocharc.json:
{ "require": ["@babel/register", "core-js/stable", "regenerator-runtime/runtime"] }
Another thing is when I change import axios from 'axios' to const axios = require('axios'), it's also working (axios isn't undefined at function execution)
c0ncentus
@c0ncentus
Hello :)
someone have idea with "--reporter-option" command line ? the doc say "reporterOption" ? -_-'' I want to put output on specific folder : /
c0ncentus
@c0ncentus
nevermind : /
Craig Taub
@craigtaub
@Gieted your example works fine for me. Perhaps try with our working babel example here https://github.com/mochajs/mocha-examples/tree/master/babel. Update the config and index and try it. Be sure to install core-js + axios.
GURU KIRAN
@AutomationGuru
Hello is there anyways i can retry the complete test suite including the before hooks ?
Craig Taub
@craigtaub
@AutomationGuru see https://mochajs.org/#retry-tests for help there. Unfortunately does not include before hook. Perhaps try —retries flag.
GURU KIRAN
@AutomationGuru
:+1: @craigtaub
pratikt1988
@pratikt1988

I've a test where:
1st process time completion time : 2019-12-08 00:00:10.000
2nd process time completion time : 2019-12-08 00:00:20.000

I've to validate if the timestamp b/w two process should be close with each other or in between? is there any way i can acheive this?

Tural Sadık
@tsadigov
for typescript or any transcompiled language, if there is a js version of the file does mocha use the existing file or does it transcompile any way?
Craig Taub
@craigtaub
@tsadigov not sure i follow, but we have an example Typescript setup https://github.com/mochajs/mocha-examples/tree/master/typescriptl have a look and see if that answers your question.
Tural Sadık
@tsadigov
thanks a lot @craigtaub . I change my moduleloader in tsconfig using AMD for using in browser and common for running node/mocha tests. Noticed that if I have my AMD/compiled js files in the directory mocha does not use transcompiler and tries to use those files with error ReferenceError: define is not defined.
When I delete generated files and npm test it runs ok
it kind of makes sense to load the file if it already exists to save computing/time. But I want to disable this. By the after successful test execution there are no transcompiled files in the directory, so probably everything is done in memory.
Tural Sadık
@tsadigov
Yesterday I solved my problem
It was because of the ts-node I am using
if there is a js file with the same name as ts file, ts-node assumes that it is ready for usage and does not transcompile using existing file. I could not find an option in ts-node to override this and I modified ts-node to match my need.
philicia
@tirzahtoh_twitter
Hi I have 2 test.spec.js tc1.spec.js and tc2.spec.js, then I do npm test, it only run tc1.spec.js not tc2.spec.js, how to make mocha run all the spec.js file? in my package.json, I have this "scripts": {
"test": "mocha --reporter mocha-teamcity-reporter $(find test -name '*.spec.js')"
}
Craig Taub
@craigtaub
@tirzahtoh_twitter try mocha --reporter mocha-teamcity-reporter *.spec.js.
Anders Moberg
@AndersMoberg

Should I be able to pass along Promises to Mocha and have the fulfillment / rejection of said Promise be used as the result for the it? Because the below testing is appearntly succeeding, whilst giving me UnhandledPromiseRejectionWarning in Node.. My presumption is that a rejection of a Promise should be a failing test.

it("should fail", function () { return Promise.reject(); })

Craig Taub
@craigtaub
tried on node v12.2 + mocha v6 and 1 failing
Anders Moberg
@AndersMoberg
@craigtaub I'm on node 10 with mocha v7 and that is failing (as in, test succeeds, Node assertion) for me.. I guess our Babel setup might be a bit busted.
Craig Taub
@craigtaub
@AndersMoberg to check with a working babel example pull https://github.com/mochajs/mocha-examples/tree/master/babel and add your test.
KiT
@KiT-Maverik

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

https://cloud.google.com/docs/chrome-enterprise/policies/?policy=CommandLineFlagSecurityWarningsEnabled

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

Lars Willighagen
@larsgw
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
@mhmdmar
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 ?