Skip to content

Failures in Before and BeforeAll hooks cause xunit & json reports to fail in parallel mode  #4624

@islembaki

Description

@islembaki

Prerequisites

  • Checked that your issue hasn't already been filed by cross-referencing issues with the faq label
  • Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
  • 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
  • Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with: node node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend that you not install Mocha globally.

Description

Failures in Before and BeforeAll hooks causes xunit & json report generation to fail in parallel mode

Steps to Reproduce

  • On any test suit with a beforeEach or before hook introduce an intentional failure in the hook
  • Run the test suite with the flag --parallel and --reporter json or --reporter xunit

Expected behavior:

  • Report is generated successfully

Actual behavior:

  • Report is not generated and the following error is thrown

  • When using json reporter

......\node_modules\mocha\lib\reporters\json.js:89
    fullTitle: test.fullTitle(),
                    ^
TypeError: test.fullTitle is not a function
    at clean (C:\Dev\reacts-api-tests\node_modules\mocha\lib\reporters\json.js:89:21)
    at Array.map (<anonymous>)
    at ParallelBufferedRunner.<anonymous> (C:\Dev\reacts-api-tests\node_modules\mocha\lib\reporters\json.js:63:26)
    at Object.onceWrapper (events.js:421:28)
    at ParallelBufferedRunner.emit (events.js:327:22)
    at ParallelBufferedRunner.EventEmitter.emit (domain.js:467:12)
    at C:\Dev\reacts-api-tests\node_modules\mocha\lib\nodejs\parallel-buffered-runner.js:347:14
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
  • when using xunit reporter
....\node_modules\mocha\lib\reporters\xunit.js:159
    classname: test.parent.fullTitle(),
                           ^
TypeError: test.parent.fullTitle is not a function
    at XUnit.test (C:\Dev\reacts-api-tests\node_modules\mocha\lib\reporters\xunit.js:159:28)
    at C:\Dev\reacts-api-tests\node_modules\mocha\lib\reporters\xunit.js:107:12
    at Array.forEach (<anonymous>)
    at ParallelBufferedRunner.<anonymous> (C:\Dev\reacts-api-tests\node_modules\mocha\lib\reporters\xunit.js:106:11)
    at Object.onceWrapper (events.js:421:28)
    at ParallelBufferedRunner.emit (events.js:327:22)
    at ParallelBufferedRunner.EventEmitter.emit (domain.js:467:12)
    at C:\Dev\reacts-api-tests\node_modules\mocha\lib\nodejs\parallel-buffered-runner.js:347:14
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Reproduces how often: 100%

Versions

  • node version v14.15.4
  • mocha version 8.3.2
  • .\node_modules.bin\mocha version 8.3.2
  • Your operating system
    • name and version: Windows 10
    • architecture (32 or 64-bit): 64-bit
  • Your shell (e.g., bash, zsh, PowerShell, cmd): PowerShell
  • Your browser and version (if running browser tests): N/A
  • Any third-party Mocha-related modules (and their versions): N/A
  • Any code transpiler (e.g., TypeScript, CoffeeScript, Babel) being used (and its version): ts-node v9.1.1

Additional Information

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: parallel modeRegarding parallel modearea: reportersinvolving a specific reportertype: buga defect, confirmed by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions