Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocha-allure v3.0.0-beta.10 isn't compatible with mocha-multi-reporters in parallel mode #1134

Open
sophiakulikova opened this issue Sep 6, 2024 · 3 comments
Labels
theme:mocha Mocha related issue type:new feature New feature or request

Comments

@sophiakulikova
Copy link

Describe the bug
The mocha-allure reporter crashes with an error "hook.error is not a function" when running tests in parallel mode

To Reproduce
Steps to reproduce the behavior:

  1. Create a simple test mytest.spec.ts
import chai from 'chai';
describe('@my-test-id-000', function () {
    it('@my-test-id-001', function () {
        chai.expect(2).to.equal(2);
    });
});

  1. Run tests with command
node ./node_modules/mocha/bin/mocha --reporter mocha-multi-reporters --reporter-options configFile=reporters.json ./tests/**/mytest.spec.*s --recursive --parallel --jobs 2
  1. The error is displayed in console
  1) Uncaught error outside test suite

  0 passing (2s)
  1 failing

  1) Uncaught error outside test suite:
     Uncaught TypeError: hook.error is not a function
      at updateFunc (node_modules\allure-mocha\src\AllureMochaReporter.ts:288:45)
      at ReporterRuntime.updateFixture (node_modules\allure-js-commons\src\sdk\reporter\ReporterRuntime.ts:166:5)
      at ParallelBufferedRunner.<anonymous> (node_modules\allure-mocha\src\AllureMochaReporter.ts:287:18)
      at ParallelBufferedRunner.emit (node:events:529:35)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async Promise.allSettled (index 0)

Expected behavior
When running tests in parallel mode all test results are correctly reported to the allure report.

Additional context
Package.lock dependencies:

"devDependencies": {
    "@babel/core": "7.15.5",
    "@babel/plugin-proposal-class-properties": "7.0.0",
    "@babel/plugin-proposal-decorators": "7.0.0",
    "@babel/plugin-proposal-do-expressions": "7.0.0",
    "@babel/plugin-proposal-export-default-from": "7.0.0",
    "@babel/plugin-proposal-export-namespace-from": "7.0.0",
    "@babel/plugin-proposal-function-bind": "7.0.0",
    "@babel/plugin-proposal-function-sent": "7.0.0",
    "@babel/plugin-proposal-json-strings": "7.0.0",
    "@babel/plugin-proposal-logical-assignment-operators": "7.0.0",
    "@babel/plugin-proposal-nullish-coalescing-operator": "7.0.0",
    "@babel/plugin-proposal-numeric-separator": "7.0.0",
    "@babel/plugin-proposal-optional-chaining": "7.0.0",
    "@babel/plugin-proposal-pipeline-operator": "7.0.0",
    "@babel/plugin-proposal-throw-expressions": "7.0.0",
    "@babel/plugin-syntax-dynamic-import": "7.0.0",
    "@babel/plugin-syntax-import-meta": "7.0.0",
    "@babel/plugin-transform-runtime": "7.12.10",
    "@babel/preset-env": "7.12.1",
    "@babel/preset-typescript": "7.3.3",
    "@babel/register": "7.12.1",
    "@types/axios": "0.14.0",
    "@types/chai": "4.2.19",
    "@types/faker": "6.6.9",
    "@types/json-bigint": "1.0.0",
    "@types/mocha": "10.0.2",
    "@types/node": "18.11.9",
    "allure-commandline": "2.28.0",
    "allure-mocha": "2.15.1",
    "axios": "0.21.1",
    "babel-plugin-module-resolver": "4.1.0",
    "chai": "4.3.10",
    "faker": "5.5.3",
    "js-sha256": "0.9.0",
    "json-bigint": "0.3.1",
    "jsonwebtoken": "8.5.1",
    "mocha": "10.2.0",
    "mocha-multi": "1.1.7",
    "mocha-multi-reporters": "1.5.1",
    "mochawesome": "6.2.1",
    "moment": "2.29.4",
    "moment-timezone": "0.5.41",
    "tv4": "1.3.0",
    "typescript": "4.9.3"
  }

Reporters.json

{
  "reporterEnabled": "mochawesome, allure-mocha",
  "allureMochaReporterOptions": {
    "resultsDir": "./output/allure-results"
  }
}
@alexander-vershinin
Copy link

@sophiakulikova Hi, I faced this issue too, but I guess you have a wrong version in the description in devDependencies.
Because bug is about v3.0.0-beta.10 version and deps are "allure-mocha": "2.15.1".

@delatrie
Copy link
Collaborator

Hi, @sophiakulikova , @alexander-vershinin
Judging by stack traces, it's definitely a beta of 3.0.0.

Could you please check if the bug can be reproduced when allure-mocha is used directly, without mocha-multi-reporters?

@delatrie delatrie added the theme:mocha Mocha related issue label Sep 11, 2024
@sophiakulikova
Copy link
Author

Hi,

@alexander-vershinin thanks for the note, indeed I attached the incorrect version in devDependencies. The problem occurs in the version v3.0.0-beta.10.

@delatrie I tried to run the following command

node ./node_modules/mocha/bin/mocha ./tests/**/mytest.spec.*s --recursive --parallel --jobs 2 --reporter allure-mocha --reporter-options resultsDir=output/allure-results

The run was completed successfully and the report was generated correctly.

Could you please advise if mocha-multi-reporters support will be added?

@delatrie delatrie changed the title Mocha-allure v3.0.0-beta.10 does not support parallel mode Mocha-allure v3.0.0-beta.10 isn't compatible with mocha-multi-reporters in parallel mode Sep 16, 2024
@delatrie delatrie added the type:new feature New feature or request label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme:mocha Mocha related issue type:new feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants