Skip to content

custom reporter is not working #132

Closed
@ivan-xue-prospa

Description

@ivan-xue-prospa

I added custom reporter in cypress.json and it works fine when doing cypress run - generating failure.log.
But when I run the tests in BS, the custom reporter is not considered and no failure.log is generated.

{
  "defaultCommandTimeout": 90000,
  "pageLoadTimeout": 90000,
  "video": false,
  "retries": {
    "runMode": 1,
    "openMode": 0
  },
  "chromeWebSecurity": false,
  "reporter": "./reporter.js"
}

reporter.js

const mocha = require('mocha');
const chalk = require('chalk');

module.exports = MyReporter;

function MyReporter(runner) {
  mocha.reporters.Base.call(this, runner);
  let passes = 0;
  let failures = 0;

  runner.on('pass', function(test) {
    passes++;
    console.log(chalk.green('Pass: ') + test.fullTitle());
  });

  runner.on('fail', function(test, err) {
    failures++;
    console.log(`${chalk.red('Fail: ') + test.fullTitle()}\n${err.message}`);
    fs.appendFileSync('./failure.log', `Spec: ${test.fullTitle()} was failed\n`);
    fs.appendFileSync('./failure.log', `Failure: ${err.message}\n\n`);
  });

  runner.on('end', function() {
    console.log('End: %d/%d', passes, passes + failures);
  });
}

mocha.utils.inherits(MyReporter, mocha.reporters.Spec);

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions