Giter Club home page Giter Club logo

Comments (6)

pmoleri avatar pmoleri commented on September 4, 2024

Hi @goelankit.
I think that condition is to prevent reporting it wrong in some nesting scenarios.
There's a unit test with failing hooks which is passing, but perhaps it's different to your case.

Could you provide more details about your case?

  • mocha version
  • which kind of hook you are using

If you could attach a minimum reproducible example it would be great.

Thanks.

from mocha-trx-reporter.

goelankit avatar goelankit commented on September 4, 2024

Hi @pmoleri ,

I think it might not be working as expected in the mocha parallel mode. I see that if I run the test in sequenced mode the report come up fine.
BTW, the same issue if the test is marked as skipped in parallel mode, the test is marked as "Inconclusive" in the output report, that also breaks our upstream workflows.

Mocha version: 8.0.1
Using "before" hook.

Please find attached the minimal repro for this.

  1. Run "npm install"
  2. Run "npm run test" to run test in parallel mode, observe Result.trx doesn't have failure entry (Not OK)
  3. Run "npm run test-seq" to run test in sequenced mode, observe Result.trx has failure entry (OK)

Similar for Skipped test showing up as "Inconclusive" in parallel mode.

  1. Uncomment this.skip (line 10) in test1.js.
  2. Run "npm run test" to run test in parallel mode, observe Result.trx doesn't have test marked as pending (Not OK)
  3. Run "npm run test-seq" to run test in sequenced mode, observe Result.trx has the test marked as pending (OK)

mochatest-trx.zip

We have our tests configured to run in parallel mode, and really looking forward to be able to consume mocha-trx-reporter in parallel mode as well.

from mocha-trx-reporter.

pmoleri avatar pmoleri commented on September 4, 2024

@goelankit
I see there are some caveats in parallel mode.
It seems it's giving us a simplified object, i.e. instead of Suite class object we get a plain JS object with only some properties.
That means that hook.parent and suite are different objects and that we don't get suite.eachTest() method, so we don't have any way to get the list of tests that were skipped due to a failed "before all" hook.

Also consider that reporting failed hooks is something that I included in this reporter, but I haven't seen in other reporters.

To sum up:
For "before each" hook, we can set the error in each test.
For "before all" hook, I don't know if there's any way to report them in TRX, because we don't have any information about the tests that did not run.

from mocha-trx-reporter.

goelankit avatar goelankit commented on September 4, 2024

@pmoleri , I think the issue is happening due to how the pending information for the test is surfaced between sequenced and parallel execution (which is perhaps a mocha issue). In parallel run, test.isPending() is how the info is available.

If I change line 97 in test-to-trx.js to,

if (test.pending === true || test.isPending() === true) {

I see the output trx report getting generated fine for for parallel runs as well now with this change. The test gets marked correctly as pending now instead of inconclusive.

I was not able to push a branch to the repo, any chance you can take a look at the change and get it in. Thanks in advance!

test-to-trx.zip

from mocha-trx-reporter.

goelankit avatar goelankit commented on September 4, 2024

Hi @pmoleri , Gentle reminder on this. Can you please check my previous reply and incorporate the change (zip file attached) in the code. Thanks!

from mocha-trx-reporter.

v-hep avatar v-hep commented on September 4, 2024

Hi @pmoleri , Gentle reminder on this. Can you please check @goelankit 's previous reply and incorporate the change (zip file attached) in the code. Thanks!

from mocha-trx-reporter.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.