allure-framework / allure-js

Allure integrations for JavaScript test frameworks
https://allurereport.org/
Apache License 2.0
230 stars 124 forks source link

allure-cucumber-js - other formatter are override while allure is enabled in config #82

Closed MichalFidor closed 7 months ago

MichalFidor commented 4 years ago

I'm submitting a ...

What is the current behavior?

I've got a package which formats the logs during test execution (cucumber-pretty). Now, while I provide Allure reporter to cucumberOpts.format together with cucumber-pretty, the 2nd one doesn't want to work.

My config file:

import { browser, Config } from 'protractor';

export const config: Config = {
  SELENIUM_PROMISE_MANAGER: false,
  allScriptsTimeout: 11000,
  directConnect: true,
  restartBrowserBetweenTests: false,

  cucumberOpts: {
    compiler: 'ts:ts-node/register',
    format: [
        'json:results/results.json',
        'node_modules/cucumber-pretty',
        'reporter/reporter.ts',
        'rerun:@rerun.txt',
    ],
    require: ['../e2e/steps/*.ts', '../e2e/support/*.ts', '../support/*.ts'],
    strict: true,
    tags: '',
  },
  framework: 'custom',
  frameworkPath: require.resolve('protractor-cucumber-framework'),
  specs: ['../e2e/features/**/*.feature'],
...
};

'reporter/reporter.ts' is a file with class Reporter for CucumberJSAllureFormatter

What is the expected behavior?

It should be able to add also other formatter for the log file.

Please tell us about your environment:

Allure version 2.7.0
Test framework protractor-cucumber-framework
Allure adaptor allure-cucumberjs @2.0.0-beta.6
Generate report using ssh allure generate...
korobochka commented 4 years ago

As far as I know, cucumber does not allow two reporters to point to the same output location (file, or stdout if file name is not provided). In your case both reporter and cucumber-pretty are set to write to stdout. Fix should be simple, just provide some file name to reporter:

format: [
        'json:results/results.json',
        'node_modules/cucumber-pretty',
        'reporter/reporter.ts:OUTPUT.txt',
        'rerun:@rerun.txt',
    ]

Note the :OUTPUT.txt, name can be any, no actual output is generated by the reporter anyway.