Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 10:07
    juergba labeled #4172
  • 06:50
    juergba labeled #4168
  • 06:50
    juergba labeled #4168
  • 06:50
    juergba unlabeled #4168
  • 01:00
    dcr007 edited #4172
  • 00:59
    dcr007 opened #4172
  • Jan 28 16:36
    ntedgi edited #4167
  • Jan 28 12:35
    ntedgi edited #4167
  • Jan 28 12:33
    ntedgi review_requested #4167
  • Jan 28 12:33
    ntedgi review_requested #4167
  • Jan 28 12:33
    ntedgi review_requested #4167
  • Jan 28 12:31
    ntedgi synchronize #4167
  • Jan 28 11:34
    ntedgi synchronize #4167
  • Jan 28 10:53
    jehy edited #4171
  • Jan 28 10:53
    jehy closed #4171
  • Jan 28 10:39
    jehy edited #4171
  • Jan 28 10:39
    jehy labeled #4171
  • Jan 28 10:39
    jehy opened #4171
  • Jan 28 10:34
    ntedgi edited #4167
  • Jan 28 08:19
    juergba labeled #4114
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 ?
Craig Taub
@craigtaub
@mhmdmar with latest v6.2.0 I did below
  1. Using fresh babel example (https://github.com/mochajs/mocha-examples/tree/master/babel)
  2. npm i mochawesome
  3. mocha --reporter mochawesome
    works for me. Perhaps something with ur configuration.
Nadia
@nadiaschutz
//why my 2nd test fails? any suggestions?

/*************calculate.js************/

function calculateSquare(number, callback) {
  setTimeout(() => {
    if (typeof number !== 'number') {
     callback('Argument of type number is expected');
     return;
    }
    const result = number * number;
    callback(null, result);
  }, 1000);
}

module.exports = calculateSquare;

/*************calculate.test.js************/

const calculateSquare = require('../calculate.js');
const expect = require('chai').expect;

describe('calculateSquare', function () {
  it('should return 4 if passed 2', function (done) {
    calculateSquare(2, function (error, result) {
      console.log('callback got called');
      expect(result).to.equal(4);
      done(); // call this when Async! 
    })
  });

  it('it should return an error if passed a string', function (done) {
    calculateSquare('string', function (error, result) {
      expect(error).to.not.equal(null);
      expect(error.message).to.equal('Argument of type number is expected');
      done();
    })
  })
});
calculateSquare
callback got called
    ✓ should return 4 if passed 2 (1008ms)
    1) it should return an error if passed a string


  1 passing (2s)
  1 failing

  1) calculateSquare
       it should return an error if passed a string:

      Uncaught AssertionError: expected null to not equal null
      + expected - actual


      at /Users/nadia/test/calculate.test.js:15:28
      at Timeout.setTimeout [as _onTimeout] (calculate.js:8:5)



npm ERR! Test failed.  See above for more details.
Craig Taub
@craigtaub
@nadiaschutz error is not an object, you have passed a string.
Change callback('Argument of type number is expected’); to callback(new Error('Argument of type number is expected'));.
Or assert on error as a string.
Nadia
@nadiaschutz
@craigtaub good catch! thanks!
Craig Taub
@craigtaub
no worries
shemar dacosta
@spookyvert
Hello!
I've been having trouble with using mocha with spectron and babel
Babel isn't transpiling my components. my test script goes
"test": "mocha --require babel-core/register"
My .babelrc
 {
    "presets": [
      [
        "env",{"targets": {"node": "current"}}
      ]
    ]
  }
Tejas Deshpande
@tkdeshpande
I am looking to click through a dynamic list of links on a page and show those in the "describe" or "it" titles. Can anyone please suggest how this can be done?
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.