by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Apr 24 17:07
    nicojs synchronize #4234
  • Apr 24 16:55
    juergba unlabeled #4251
  • Apr 24 15:47
    Daniel0113 edited #4219
  • Apr 24 15:45
    Daniel0113 edited #4219
  • Apr 24 15:11
    Daniel0113 synchronize #4219
  • Apr 24 14:01
    juergba labeled #4227
  • Apr 24 14:01
    juergba unlabeled #4227
  • Apr 24 14:01
    juergba unlabeled #4227
  • Apr 24 13:58
    juergba edited #4251
  • Apr 24 13:33
    juergba labeled #4251
  • Apr 24 12:52
    juergba milestoned #4251
  • Apr 24 12:52
    juergba labeled #4251
  • Apr 24 12:52
    juergba labeled #4251
  • Apr 24 12:52
    juergba labeled #4251
  • Apr 24 12:51
    juergba assigned #4251
  • Apr 24 12:51
    juergba review_requested #4251
  • Apr 24 12:51
    juergba opened #4251
  • Apr 24 12:37

    juergba on karma

    type check before calling retri… (compare)

  • Apr 24 06:26
    juergba labeled #4250
  • Apr 24 06:26
    juergba labeled #4250
Craig Taub
@craigtaub
:thumbsup:
anlex N
@anlexN
nodejs/help#2919
https://user-images.githubusercontent.com/8686739/90384671-834fc680-e0b4-11ea-90c0-94ae3b58eee5.png
inquirer is a solution, but i don't like framework. i also reviewed docs readline, repl, tty, there is no such api. only rl.question is maybe one, but it is not select/options menu.
who can help me?
Daniel Von Fange
@DanielVF
Greetings! I'm somehow unable to get the object inside a chai asserter method.
chai.Assertion.addMethod('balanceOf', async (amount) => {
    console.log(this._obj) // undefined
    console.log(this) // {}
    console.log(chai.util.flag(this, 'object')) // undefined
});

expect("bob").to.have.a.balanceOf("5")
for the life of me, I can't find a way to get "bob" inside the balanceOf assertion.
What am I missing?
I'm using chai 4.2.0
Peter Müller
@Munter
I think you might have more luck going to the chai project than the mocha support channel
Daniel Von Fange
@DanielVF
Sounds good.
Daniel Von Fange
@DanielVF
Found the issue. The arrow function here rebinds the this-scope to where this code is running. You have to use function, not the fat arrow.
Jacob Bogers
@Jacob_Bogers_twitter
this is my .mocharc.js file its not being picked up by "mocha" command

'use strict';
module.exports = {
    diff: true,
    bail: true,
    sort: true,
    exit: true,
    colors: true,
    'full-trace': true,
    recursive: true,
    extension: ['js'],
    opts: false,
    bail: true,
    reporter: 'landing',
    'check-leaks': true,
    package: './package.json',
    //slow: 75,
    timeout: 0,
    color: true,
    ui: 'tdd',
    watchFiles: ['test/**/*.spec.js']
};
there is one test file in test/pfd/demo.spec.js but it doesnt see it
.mocharc.js itself is in the root of the project dir
Can someone help?
Jacob Bogers
@Jacob_Bogers_twitter
O forget it, i was using mocha v2 instead of mocha v8
the project was a bit dated
Aleem Iqbal
@AleemIqbal
My Company Contributed to mochajs any idea how long does it take to get featured on homepage?
Peter Müller
@Munter
@AleemIqbal it will show up on the next build, unless your company matches our block list. I think we do a nightly build of the web page now if I recall correctly
Nathaniel Cailo
@nathanie0221_gitlab
Hi, I'm looking to make my logs more informative. I've discovered beforeEach and afterEach, I used them to create logs before and after the it blocks are run, is it also possible to log the describe blocks?
I tried it in the beforeEach/afterEach and it just ended up showing the describe title in all it blocks
Evgeny Poberezkin
@epoberezkin
Hello! Could anybody help with this issue? istanbuljs/nyc#1348 ? In short, when mocha is used with ts-node, nyc does not pick up source maps of compiled typescript files. Thank you!
Craig Taub
@craigtaub
@nathanie0221_gitlab not sure what you mean by “log the describe blocks”. The describe block is a "test suite", a “suite" consists of test files. The reporters log output for hooks (before/after each) tests and suites. You should try not to execute code in describe block, just variables..use test and hooks.
nikithauc
@nikithauc
Hello! I added a new test file on a local branch say Branch1. Later I switched to new git local branch - Branch2 which did not contain the newly added test file. However, when I ran the tests on Branch2 I found that newly added tests of Branch1 where also running. How do I solve this problem?
Craig Taub
@craigtaub
@nikithauc are you sure the test file is not there on Branch2? mocha traverses physical files and folders so if its not there it should not run. if you are running a compiled version perhaps try cleaning first.
Amit Krishna
@amitkrishna
Hello all , How to add gecko driver for Selenium test in Mocha script
Craig Taub
@craigtaub
@amitkrishna not used gecko before, but you can see most of the selenium setup in our mocha-examples repo https://github.com/mochajs/mocha-examples/blob/master/packages/selenium/test/selenium.spec.js. Then I assume swap chromedriver for gecko.
Amit Krishna
@amitkrishna
How to use Sleep function in Mocha
Alok
@alok92
Hi All
I'm trying to run mocha tests & it doesn't seem to ignore the config files or just run a specified test even when a full path to test file is given
./node_modules/.bin/mocha test/index.spec.js --exclude 'config' --exclude 'node_modules'
I've tried multiple variations of it & everytime it starts with trying to run a js file in config directory
Craig Taub
@craigtaub
@alok92 you should not need —exclude options if you are only giving 1 test suite. Does the index.spec.js require the js file in config directory in its dependency tree anywhere?
Alok
@alok92
thanks @craigtaub, I figured it out. It was the unsupported export which was causing it. My spec file was importing a file which in turn was importing this config file. I installed esm as a dev dependency & did a --require esm & it worked all right. Although the tests all failed, haha
Jared Evans
@JaredCE
Is there a way of saving mochas output?
at the moment i run mocha in a docker container like so: ENTRYPOINT [ "mocha", "--config", "./test/.mocharc.js"]
Jared Evans
@JaredCE
anyone know how to save the output from mocha?
Craig Taub
@craigtaub
@JaredCE you can the json reporter and store like mocha --reporter json > results.json. Very easy to process in this format.
Or use approach for html/markdown/xml reporters.
Jared Evans
@JaredCE
so changing to this: ENTRYPOINT [ "mocha", "--reporter json > results.json", "--config", "./test/.mocharc.js"]
Eric
@audioscavenger
hi all! does anyone knows how to change the mocha default passed test check-mark character?
Eric
@audioscavenger
for the spec reporter
Juerg B.
@juergba
@audioscavenger it's hardcoded in mocha\lib\reporters\base.js
Richard Littauer
@RichardLitt
I'm trying to run the basic example in Getting Started on the main home page, and I'm getting an error.
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined. I don't understand where this error is coming from.
Got it.
The issue was that I needed to define where Mocha was testing. The test script calling 'mocha' in the package.json should probably be changed to 'mocha test/*js.'. https://mochajs.org/#getting-started
Amit Krishna
@amitkrishna
I am getting this error: '
'''UnhandledPromiseRejectionWarning: ElementClickInterceptedError: Element <button id="__button2" > is not clickable at point (1124,66) because another element <div id="shieldlayer-id-1600148583053-10" class="UiPopupShield"> obscures it''''
While running selenium with mocha How to fix this?
Craig Taub
@craigtaub
@amitkrishna that depends on your setup i guess, sounds like a selenium error. Im afraid w/o seeing code all I can suggest is checking your setup is correct against our example (https://github.com/mochajs/mocha-examples/tree/master/packages/selenium).
Pavlin Stoenchev
@pavlin117_gitlab
Hello Everyone, does someone know why my tests exit with code 0 when there is actually a failed test ?
rembeckyb
@rembeckyb_twitter

Is it possible to print a variable in an "it" statement title? For example:

describe("Get Build Version", function () {

    let buildVersion;

    it("Retrieve build version", function () {
        buildVersion = common.getBuildVersion();
        expect(buildVersion).to.not.equal('undefined');
    });

    it("Build Version: " + buildVersion, function () {
        expect(buildVersion).to.not.equal('undefined');
    });
}

However, the printed buildVersion in the second "it" statement title shows as undefined, despite properly retrieving the build version. The tests pass fine, and console.log(buildVersion) shows the variable has its intended value, but still the "it" statement title shows as undefined.
How can I have it show the proper variable value?

rembeckyb
@rembeckyb_twitter

I've changed to this code based off a solution I found online, but it still doesn't work.

describe("Get Build Version", function () {

    let buildVersion;

    it("Retrieve build version", function () {
        buildVersion = common.getBuildVersion();
        expect(buildVersion).to.not.equal(false);
    });

    it("Build Version: ", function () {
        this.test.title = this.test.title + buildVersion;
        console.log(this.test.title);
        expect(buildVersion).to.not.equal(false);
    });
}

Even stranger is that the console.log(this.test.title); prints properly, but the test title is still reported as simply "Build Version: ". What am I doing wrong?

Craig Taub
@craigtaub
@rembeckyb_twitter its relating to the ordering mocha runs a suite. With test titles + using a variable. The variable could be set in “before”/“beforeEach" hooks or the “describe" context itself, but not in a test. Abit of info on https://mochajs.org/#run-cycle-overview, it runs the test functions last.
Lukas Wilkeer
@lukaswilkeer

HI folks, I'm having trouble using beforeEach hook. A can't define a variable calling a function.

The code is:

let user;
let db;

beforeEach(async () => {
  const password = generatePassword('******')

  user = {
    account_type: 0,
    email: '*****@*****.com',
    password: password,
    name: 'Lukw',
    last_name: 'wilkerson',
    permission: 1
  }

  db = await model
})

The error is: Error message

Causing a type error: Cannot read property 'password' of undefined