Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Sachu Shaji Abraham
@sachushaji
"@babel/register": "^7.0.0",
Can anybody give info why i am getting error?
Javier Pons
@JavierPons
any idea how to run the test from terminal to react component front. I mean that running test in terminal past to react component and it show the test failed and passed?
Craig Taub
@craigtaub
@sachushaji the error Cannot read property 'QUORUM_SIZE' of undefined tells you its relating to location of that property. I’d look at where that comes from.
@JavierPons i do not follow what u mean. We have an example using React setup here https://github.com/mochajs/mocha-examples/tree/master/react-webpack.
Nitesh Pandey
@saiyeek
Hi, I am trying to create a custom mocha reporter with typescript, but seems like I am unable to set types correctly, has anyone written a custom mocha reporter with typescript?
Nitesh Pandey
@saiyeek
Getting something like Could not find a declaration file for module 'mocha/lib/reporters/base'. '/Users/abc/projects/opensource/remote-mocha-reporter/node_modules/mocha/lib/reporters/base.js' implicitly has an 'any' type. Try `npm install @types/mocha` if it exists or add a new declaration (.d.ts) file containing `declare module 'mocha/lib/reporters/base';`ts(7016)
Javier Pons
@JavierPons
@craigtaub Im running an api test with Mocha Chai. at the same time I have Front page done with React. Is it possible to show/run the test, done in the api( that shows in terminal), in the Front Page (React)? I don't want to test React components, that it is what Enzyme is for.
Craig Taub
@craigtaub
@JavierPons are you talking about automated testing on a real browser? i.e. karma/selenium/cypress?
@saiyeek could u supply the code for your reporter pls?
Javier Pons
@JavierPons
@craigtaub thanks for the help
menendezau
@menendezau
Hey guys! Could anyone point me to a getting started guide where I can get to know how to setup testing for browser-based javascript, but to be run locally (nodejs)?
^ Complications come when browser-side code is required to do an exports.something which is not browser-compatible
Craig Taub
@craigtaub
@menendezau we have a working example of Karma here (https://github.com/mochajs/mocha-examples/tree/master/karma). Run on Nodejs but testing browser app.
We also have a Selenium example there.
Hope that helps
KiT
@KiT-Maverik
Hey guys
Does anybody know, is it possible to assign custom statuses to tests?
For instance, I wanna conditionally fail test, and that failed test should receive "onditionally failed" status.
Craig Taub
@craigtaub
@KiT-Maverik does this entry in the Wiki on conditionally failing help https://github.com/mochajs/mocha/wiki/HOW-TO:-Conditionally-fail-a-test-after-completion ?
KiT
@KiT-Maverik
@craigtaub no. this is about conditionally failing tests. And I want to conditionally set STATUS of failed tests.
I have custom functional in my framework. It fails all tests in set if hook is broken. Currently all those tests come with "failed" status. So, i'm wondering, is it possible to force change their status to "unknown"/"cancelled" or smth like this
philicia
@tirzahtoh_twitter
sorry, I got it
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