DevExpress / testcafe

A Node.js tool to automate end-to-end web testing.
https://testcafe.io
MIT License
9.82k stars 671 forks source link

Add a separate property for the reporter factory function #6286

Closed mokone91 closed 1 year ago

mokone91 commented 3 years ago

Seems it's not possible to use local reporter using config file now. Its can be wery useful feature, especially as is possible with js interface.


{
    reporter: [
        {
            'name/path': 'test/reporter.ts',
            'output': './e2e_report.xml'
        }
}
Dmitry-Ostashev commented 3 years ago

This functionality will be available after we support the JS configuration file. You will be able to load your reporter using the require method. Please track the following issue to be notified of our progress: https://github.com/DevExpress/testcafe/issues/5109

mokone91 commented 2 years ago

Hi! seems js configuration already implemented, is there any guide which shows how can i use my local reporter?

Dmitry-Ostashev commented 2 years ago

Hi @mokone91,

You can specify your local reporter in the JS configuration file in the following way:

.testcaferc.js

const reporter = require('./reporter');

module.exports = {
    reporter,
    browsers: 'chrome',
    src: ['test.js']
}
mokone91 commented 2 years ago

Hi! So i have implemented it using next snippet:


const customReporter = require('./customReporter');

module.exports = {
  ...
  reporter: [
    {
      name: 'spec'
    },
    {
      name: customReporter,
      output: './reports/e2e_report.xml'
    }
  ],
}

and seems it works as expected, the only point here - I passing reporter as name 🙃

miherlosev commented 2 years ago

@mokone91

It occurred due to the parsing reporting parameters algorithm. It's not part of a public API and can be changed at any time. Please, use the approach from the https://github.com/DevExpress/testcafe/issues/6286#issuecomment-979916850.

mokone91 commented 2 years ago

@mokone91

It occurred due to the parsing reporting parameters algorithm. It's not part of a public API and can be changed at any time. Please, use the approach from the #6286 (comment).

Hi @miherlosev

But how then I can select multiple reporters and configure outputPath for custom?

miherlosev commented 2 years ago

Hi @mokone91

We discussed this with @AndreyBelym one more time and decided the following:

  1. We should make a separate property for a reporter if it's specified as a factory function.
    
    const customReporter = require('./customReporter');

module.exports = { ... reporter: [ { reporter: customReporter, <--- new property output: './reports/e2e_report.xml' } ], }



2. The `name` property should accept only the `string` name of a reporter. We should raise a warning if the value of the another type is accepted.
3. We recommend using the `name` property until the new property is implemented.
AlexKamaev commented 1 year ago

Since there is a workaround (using the name property) and the issue is not popular among TestCafe users, we decided to close it.