reportportal / agent-js-mocha

Agent to integrate Mocha with ReportPortal.
https://www.npmjs.com/package/@reportportal/agent-js-mocha
Apache License 2.0
15 stars 14 forks source link

mocha-multi-reporters not working with agent-js #90

Closed ShMajed closed 1 year ago

ShMajed commented 1 year ago

Hey,

I'm trying to use mocha-multi-reporters to have two reports, the issue is that the report portal is not showing any reports after passing it in the report option

my mocharc file looks like this

reporter: 'mocha-multi-reporters',
  'reporter-option': [
    'reporterEnabled:@reportportal/agent-js-mocha, tap',
    'endpoint=https://reportportal.xxxx.dev/api/v1',
    'token=xxxxxx,
    'launch='+process.env.LAUNCH,
    'project='xxx',
    'description='',
  ],

is there a way to make this possible?

TAVkiev commented 1 year ago

@ShMajed you should use programmatic way

new Mocha({ reporter: 'mocha-multi-reporters', reporterOptions: { reporterEnabled: 'spec,mocha-junit-reporter,@reportportal/agent-js-mocha', mochaJunitReporterReporterOptions: { mochaFile: 'path.xml' }, reportportalAgentJsMochaReporterOptions: { token: 'xxxx', endpoint: 'endpoint', project: 'project', launch: 'launch', description: 'desc', } } });

nixpix commented 1 year ago

I got it working with a config like this File: multi-reporter-config.json

{
    "reporterEnabled": "mochawesome, @reportportal/agent-js-mocha",
    "mochawesomeReporterOptions": {
        "code": false,
        "charts": true,
        "reportFilename": "[datetime]-[name]",
        "timestamp": "isoDateTime",
        "json": true,
        "html": true
    },
    "reportportalAgentJsMochaReporterOptions": {
        "token": "00000000-0000-0000-0000-000000000000",
        "endpoint": "https://your.reportportal.server/api/v1",
        "project": "YourReportPortalProjectName",
        "launch": "YourLauncherName",
        "attributes": [
            {
                "key": "component",
                "value": "something"
            },
            {
                "key": "test-suite",
                "value": "regression"
            },
            {
                "key": "environment",
                "value": "development"
            },
            {
                "key": "component-version",
                "value": "4.0.0"
            },
            {
                "key": "languages",
                "value": "language"
            }
        ]
    }
}

And using the following command in package.json scripts

"regression": "mocha --reporter mocha-multi-reporters --reporter-options configFile=./multi-reporter-config.json ./tests/*",

Hope this helps.

ShMajed commented 1 year ago

@nixpix works perfectly, thanks for the help 🚀