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
Khairi Husseini
@khusseini
ah with async/await it works fine
William Entriken
@fulldecent
Hi Room. Happy Sunday Hackday
brt
@brtjob_twitter
so what's the deal, no way to override mocha color defaults?
will I have to alter my color scheme?
or (god forbid) configure it manually in every project, forcing my workflow specifics on everybody else?
Smart QA Lead
@chan90git

HI Pals,

I am looking for implementing distributed execution for our mocha test automation framework.
Currently we have Mocha-Parallel + NodeJs + Selenium + Jenkins in our framework. And Im planning for execution of tests by splitting into multiple tests and each running in parallel in multiple jenkins salve nodes in parallel [the test should be split automatically - like its handled in mocha-parallel] and only one report should be produced for a build.

ex. 1 build in jenkins -> 50 suites -> automatically split them equally and run in 3 salves with 4 parallel threads in each salves -> once all tests are executed only one combined mochawesome report should be generated -----> is this possible ?

Would be extremely grateful, if someone could help me out here.

Thanks,
Chan

Sebastian T F
@sebastiantf
Is it still the case that we cant set env vars using mocha config files? If yes, why is it like that? Wouldn't that be a useful feature to allow setting some env vars for all mocha test using config files?
1 reply
Oleksandr Tsymbaliuk
@TAVkiev

hi all, hope someone met it before
I am observing strange behavior when I am using "grep" function.
mostly the problem is in this method:
var match = self._grep.test(test.fullTitle());
(node_modules\mocha\lib\runner.js )

from time to time also here (where _grep.test is using):
this.grepTotal(this.suite)
from:

Runner.prototype.grep = function(re, invert) {
  debug('grep(): setting to %s', re);
  this._grep = re;
  this._invert = invert;
  this.total = this.grepTotal(this.suite);
  return this;
};

The problem that method var match = self._grep.test(test.fullTitle()); outputs false, while it should be true, but only for some 'it' (tests). My describe has 2 it, one is passed, the other not visible because of condition 'false'
At the same time, this method Runner.prototype.grep is showing 2 'it', but this thing self._grep.test(test.fullTitle()) is validating only one. In some cases both of methods skips some 'it'.
Example:
this one 'it' not visible:
this is some description @testing @testing-smoke Ensure dashFeeSensitivity exist
while next 'it' works:
'this is some description @testing @testing-smoke Ensure dashMaxFloor exist'

bot of them should return 'true'

/@testing |@testing$|@testing-smoke |@testing-smoke$/g.test('this is some description @testing @testing-smoke Ensure dashFeeSensitivity exist')
/@testing |@testing$|@testing-smoke |@testing-smoke$/g.test('this is some description @testing @testing-smoke Ensure dashMaxFloor exist')

Any help is very appreciate !

Dev
@Charan83
Hi everyone,
Added reset() in config, beforeTest.
But this results in, resetting twice for the first test, in each spec. As for each new spec, wdio creates a new session and the app gets reset.
Is there a way, may be in beforeTest hook, to avoid reset() the app for the first test in the spec file as it will be done anyway as its new spec file and a new session is created?
edgar-koster
@edgar-koster
Hi all. I understand how I can skip a test with (condition ? it : it.skip) Now what I want to do. I can add a bolean to the code to be false and put that in the condition so it skips. Now I try to set the boolean in the before and then it doesn't work. I know the boolean changes in the before, but it doesn't run the test. Can you do something like this, so set a variable in the before to run the test? Example, I set the boolean with true if an element extists. A first it expects this boolean to be true (works). A second it should do something with the content. But if the element is not there there is no need to try the test, hence the skip.
Juerg B.
@juergba
Mocha runs in cycles, see RUN CYCLEs, especially item 8.
When describe() runs, the test runner will be built, but no hooks or tests are executed, yet. So setting your boolean in a hook, will not work. It's too late.
There is the dynamic this.skip() you can use for that.
edgar-koster
@edgar-koster
Thanks, I just did that for these types of boolean checks. I add an if (condition) this.skip() to the test where needed
Bryce Carr
@bdcarr

Hey friends, is there a way to stop a suite mid-execution while allowing after() hooks to run? I've got a long-running suite that does cleanup at the end, and often I'll identify an issue early on and want to restart the suite. My options are to let it finish and do the cleanup properly, or kill the script and clean things up myself.

I tried setting a breakpoint inside an it() and entering this.test.parent.pending = true in the debugger console, but this seemed to skip the after hook.

2 replies
lunchtime_o_boulez
@lunch_stuff_twitter
Hi all. Has anyone upgraded mocha to v9 while continuing to use the esm package?
2 replies
Smart QA Lead
@chan90git
image.png
Hi folks,
Im using Mocha for our Selenium automation. Post Jenkins setup (enabling .net) in my Windows machine, im facing this issue. I cant use npm, yarn or any other package i used earlier.
I made no changes to npm setup. Just installed jenkins slave service via winsw.exe and its working fine. Post this setup, my mocha is making trouble. Im struck here. Can someone rescue me ?
Smart QA Lead
@chan90git
this cmd worked fine earlier -> yarn run parallel tests/....js , but now it says (jenkins log)
  • APP_URL=https://some.url.com/
  • HEADLESS=false
  • yarn run parallel tests/dir/sometest.js --retries 2 --reporter mochawesome --reporter-options reportFilename=amochawesome_14_Aug_2021_04_00_37_CUT,charts=true,enableCode=false
    C:/qa/workspace/DIR@tmp/durable-7e5c293d/script.sh: line 168: yarn: command not found
nopeless
@nopeless
I just realized a specific problem for me
Basically, --watch watches all files, and I'm writing a test that modifies the files
so it runs recursievly
My bad, I had to type [\".json\"] instead of .json
Igor Rubis
@igor-rubis
Hi all.
Can anyone please help me with handling assertion errors in mocha?
I want to use try-catch on a block of code. After an error is caught I want to do some logging and then throw it to fail the test.
Igor Rubis
@igor-rubis
The issue is that test fails without visiting the catch block.
Moriz Büsing
@buesing

hi everyone! i just tried upgrading to 9.0.3 and i'm getting a TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts". Running (obviously) on typescript, with the command
TS_NODE_PROJECT='./tsconfig.test.json' mocha -r ts-node/register -r tsconfig-paths/register 'src/**/*.test.ts'.
this is my tsconfig.test.json:

{
  "compilerOptions": {
    "moduleResolution": "node",
    "target": "es5",
    "module": "commonjs",
    "lib": ["es2015", "es2016", "es2017", "esnext", "dom"],
    "strict": true,
    "sourceMap": true,
    "declaration": false,
    "strictNullChecks": false,
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": false,
    "resolveJsonModule": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "esModuleInterop": true,
    "baseUrl": "src",
    "paths": {
      "@pages/*": ["pages/*"],
      "@components/*": ["components/*"],
    },
    "typeRoots": ["node_modules/@types"]
  },
  "include": ["src"]
}

any ideas?

jimmybirrias
@jimmybirrias
Hello here, one question: is there a way to avoid this kind of error messages?
Error: Timeout of 60000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
nopeless
@nopeless
@igor-rubis I use chai
@jimmybirrias we need to see what that function looks like
jimmybirrias
@jimmybirrias
@nopeless my test function is a empty test
it("empty function", function(done) {
});
Konstantin Bläsi
@konstantinblaesi
@jimmybirrias you need to either add done();to the body or make the test function an async funtction
jimmybirrias
@jimmybirrias
yes, I have noticed it but is there way to avoid the timeout error?
Konstantin Bläsi
@konstantinblaesi
it("empty function", async function() {
});
this would also work
@jimmybirrias have you tried without the done parameter? Maybe mocha is smart enough to not expect done to be called then
otherwise I assume no, personally I would just do either of the two above
mocha just assumes the test is not done until this callback named done here is called
Konstantin Bläsi
@konstantinblaesi
If your test is completely synchronous you'd not need a done callback or async function technically, but node / javascript code is very async in nature so you'll probably want it in most cases
Pavlína Wurzel Gonçalves
@WPavlina_twitter

Hi! I am in a research team doing a study about what skills are needed for efficient code reviews and how to help developers improve their personal code review practice. We would be very grateful if you would consider participating in the study!

https://www.uzh.ch/zi/cl/umfragen/index.php/657931?lang=en

Pavlina, Gul, Alexander and Alberto
University of Zurich, Eindhoven University of Technology

Smart QA Lead
@chan90git
Mocha merge shows incorrect Duration and Suites - post merging multiple json files -> Antontelesh/mochawesome-merge#71
is anyone facing similar issue ?
Konstantin Kostiuk
@SET001
is it possible to suppress the output of test failure details?
3 replies
Julian Gonggrijp
@jgonggrijp
Hey folks I see I can skip a test dynamically by calling this.skip(). I would like to do something similar, but marking the test as successful instead. Is there a way to do that? I couldn't find the class or object that has the skip method in the API documentation.
2 replies
Vlad Danilov
@danilovxp
Hi all,
In the file I have before() after() describe and it. I would like to run only one it, I know about .only, but I always should comment before and after. Is there a way how can I run only one it without commenting before and after? Thank you in advance.
1 reply
SNDST00M: M.U.N.I.N
@SNDST00M
2 replies
SSrideve
@SSrideve
image.png
Hi ! I joined this chat room today. Anyone aware why I get "Error: Cannot find module '@babel/register'" while running mocha tests. I am trying to run in a docker. Appreciate any pointers. thanks !
6 replies
SSrideve
@SSrideve
image.png
SSrideve
@SSrideve
Hi ! In mocha I see error as AssertionError: expected 500 to equal 200 but testcase shows as pass. Any clue how to make such cases fail or something missing ??
2 replies
John Smeeth
@johnsmeeth0210_twitter
hi all, i got this error TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for projectRoot/test/a.spec.ts when run npx mocha. Can any body give me an advise?
1 reply