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 2020 17:07
    nicojs synchronize #4234
  • Apr 24 2020 16:55
    juergba unlabeled #4251
  • Apr 24 2020 15:47
    Daniel0113 edited #4219
  • Apr 24 2020 15:45
    Daniel0113 edited #4219
  • Apr 24 2020 15:11
    Daniel0113 synchronize #4219
  • Apr 24 2020 14:01
    juergba labeled #4227
  • Apr 24 2020 14:01
    juergba unlabeled #4227
  • Apr 24 2020 14:01
    juergba unlabeled #4227
  • Apr 24 2020 13:58
    juergba edited #4251
  • Apr 24 2020 13:33
    juergba labeled #4251
  • Apr 24 2020 12:52
    juergba milestoned #4251
  • Apr 24 2020 12:52
    juergba labeled #4251
  • Apr 24 2020 12:52
    juergba labeled #4251
  • Apr 24 2020 12:52
    juergba labeled #4251
  • Apr 24 2020 12:51
    juergba assigned #4251
  • Apr 24 2020 12:51
    juergba review_requested #4251
  • Apr 24 2020 12:51
    juergba opened #4251
  • Apr 24 2020 12:37

    juergba on karma

    type check before calling retri… (compare)

  • Apr 24 2020 06:26
    juergba labeled #4250
  • Apr 24 2020 06:26
    juergba labeled #4250
Josh Goebel
@joshgoebel
https://gist.github.com/joshgoebel/40d89450a8cd7c653d98f8fa225c208f i don't like that i have to lose the namespacing but to make modules work inside you have to await them and that seems to silently break the tests
is there some way to have cake and eat it too, or is this just a limitation that there is no way around?
Juerg B.
@juergba
@joshgoebel Mocha supports Node's native ESM implementation.
Josh Goebel
@joshgoebel
I don't think that answers my question at all.
This is all using Node's native ESM. The question is: How to use modules and ALSO keep the hljs namespacing for the test suite.
just making the function async and using await import failed silently
is there a way to resolve that?
Juerg B.
@juergba
You can't use describe in an async way, this has nothing to do with ESM and will not change in near future. Only hooks and tests can run async functions. Try a before hook, which should share the same context as describe. I'm not sure though, you have to test.
Josh Goebel
@joshgoebel
well, i'm not making proclamations bout "has to do with ESM" (or not) only saying it was trivially possible with require but seems impossible with ESM... I'm just making sure that I'm not missing something. It sounds like it's simply not possible. It was just about seeing the output of the tests grouped nicely when running them.
Since it's not possible is there any real benefit it upgrading our test suite to use ESM vs just continuing to use require?
iniatse
@iniatse
why is there no error if I use an undefined variable within it(<here>, function() {...})
?
it just wait for the timeout
3 replies
Josh Goebel
@joshgoebel
@juergba Is there any real benefit to use modules with Mocha vs just continuing to use require?
20 replies
dimtabu
@taburetkin

node flags can be defined in Mocha’s configuration.

configuration section describes what the filename config should have and also provides a link to configuration examples
but i can't see node flags
can someone point me?

3 replies
Daniel Guldberg Aaes
@notaduck
Hi there. I have a function called bmi in 3 files, how would I test the same function in all 3 files without referencing each file? There is 50 more files which is coming and I need to test the bmi function in each file.
dimtabu
@taburetkin
i just faced with some strange behavior.
yarn mocha runs all tests without exceptions but yarn mocha --watch throws Must use import to load ES Module: [path to my test file]
in package json i have "type":"module"
it seems that when in watch mode there is internal require instead of import, i suppose.
dimtabu
@taburetkin
ah, i see. esm in watch mode not yet supported
Alexandre Grs
@alexgrs_gitlab
hello ! I was wondering if in an afterEach it was possible to change the state of a given test ? I'm using this.currentTest.state ='failed' but it does not seem to change the state of the test sadly
Sandeep1217
@Sandeep1217
can we use mocha chai for both UI Testing and API testing?
vovanoid89
@vovanoid89
Hi. Could anybody help please
I want to use in autotest inside it some delay between every retries, example 4 retries and 10 seconds between reties. Tried to find mocha methods..but can't find it..
Example:
it('some test', async function () {
this.retries(4);
//some delay between retries
.....
}
WORMSS
@WORMSS
From what I can tell of https://github.com/mochajs/mocha/blob/master/lib/runner.js#L816 there is NO delay
@vovanoid89
Dmytro Kuznetsov
@dkuznetsov21
so, how to add some delay between retries?
WORMSS
@WORMSS
From what I can tell of https://github.com/mochajs/mocha/blob/master/lib/runner.js#L816 there is NO delay
You can add a delay between 'ALL' tests, regardless of pass/fail/retry, using beforeEach but I don't believe you can pick and choose when to add a delay
Dmytro Kuznetsov
@dkuznetsov21
There must be some workaround to create delays between retries
WORMSS
@WORMSS
well, YES. I given you the file above. Fork Mocha and add the functionality.
it('should blar', async () => {
  try {
    // my tests
  } catch (err) {
    await delay(400);
    throw err;
  }
});

function delay(time) {
  return new Promise(r => setTimeout(r, time));
}
Dirty hack I could think of.
Dmytro Kuznetsov
@dkuznetsov21
thank u @WORMSS
will be trying
Iván Pazmiño
@iapazmino
hi! I'm having some trouble configuring a mocha test suite over a react&webpack application and was wondering if this is the correct place to make my question
Dmytro Kuznetsov
@dkuznetsov21
image.png
@WORMSS @vovanoid89 find a solution
Iván Pazmiño
@iapazmino
I'm trying to setup mocha to test a react suit
I'm running it requiring babel/register and env and react presets
react preset targets node in current version and useBuiltIn is usage with corejs 3.10
but, when run it throws an index out of bounds java exception cCaused by: Attached Guest Language Frames (9)
any clue where I should be looking at?
Juerg B.
@juergba
@iapazmino we have a react setup sample in our sample repo. Maybe that helps.
falconwoods
@falconwoods
Hi there, can anyone tell me how to output log in mocha, like console.log
it really drives me crazy :(
ashkank83
@ashkank83

Hi All, Basic question!
I need to develop end2end testing for a series of softwares that we have developed in house and I wonder if Mocha is the right tool for it?
A typical test scenario in our case consists of following steps (which is done manually at the moment)

  1. Invoke a Soap API to create an object (Soap call)
  2. Check MS SQL to make sure records are created (MS SQL statement)
  3. Wait for an in house developed software to move the record to Oracle DB and verify
  4. Verify Oracle DB to make sure synchroniser passes the test (Oracle statement)
  5. Invoke XML over http API and verify the result (invoke API and check XML)

Ideally I want to be able to let testers to write these test scenarios and add to the list of tests to be performed with every new version released. Would you recommend Mocha?

Andrey Nalivaiko
@Andrei1982
Hi. How to specify target directory in mocharc.js file for allure results?
reporterOption: {
targetDir: "./testing/allure/allure-results",
} - doesn't work
mocha v.8
Anyone can help me?
Juerg B.
@juergba
@Andrei1982 reporterOption is an array => see .mocharc.js
Andrey Nalivaiko
@Andrei1982
@juergba reporterOption: ["targetDir=./testing/allure/allure-results"] - doesn't work too
Andrey Nalivaiko
@Andrei1982
Anyone else can help? No one doesn't use a custom directory for allure result reports?
Russell Anthony
@russell-dot-js
👋
I'm trying to resolve some flakey integration tests I'm not particular proud of. The problem is that a lot of our assertions require waiting for side effects (up to a threshold), but when running large #'s of tests in parallel, that data pipeline can take a little bit longer than we expect. So this can resolve in 1/1000 tests failing due to a condition not being met in a beforeEach hook. I'd like to quickly hack to stop the bleeding and prevent all the lost time of a single test "failing" despite increasing timeout (it only needs to go up and up as the number of tests and amount of data goes up, resulting in tests that could be fast becoming slow to accomodate the one that will fail). What's the best way to monkeypatch beforeEach so that it follows mocha's retry logic? I'm not talking about adding a custom beforeEach, because I don't want to impact developer QOL or have to enforce "you must use this special beforeEach!" when in reality all tests work perfectly on their own and to the individual developer, it's only when running large numbers of tests in parallel (CI) that we see issues
Miguel Ike A. Dumancas
@ikedumancas
Hello. Why is it that ctx is missing when running parallel?
Eric Scaglioni Ferreira
@ericscaglioni
Hi guys.
Is there a way to 'pass with no tests' like Jest does?
I mean, I'm setting up a new app with mocha and I added a testing validation on pre-push hook. The problem is that at this moment I still have no tests. I'm on the beginning, just want to let the project ready for when it starts. Any thoughts?
Boone Ferry
@ChandlerFerry
How do I convert CLI ran mocha into new Mocha()? There are no "require" or "extension" options for TypeScript.