BorisOsipov / wdio-reportportal-reporter

A WebdriverIO plugin. Report results to Report Portal.
MIT License
23 stars 29 forks source link

Following errors occurs in console when AND reportportal reporter disabled in wdio conf #41

Closed BorisOsipov closed 5 years ago

BorisOsipov commented 5 years ago

"wdio-reportportal-reporter": "^0.0.21"

Following errors occurs in console when: onComplete: async function (exitCode, config, capabilities) { await reporter.waitLaunchFinished(); } AND reportportal reporter disabled in wdio conf: reporters: ['spec', 'dot', /*'reportportal'*/],

TypeError: Cannot read property 'helpers' of undefined at Function. (/Users/208821/Projects/np-cooking/api/test/e2e/node_modules/wdio-reportportal-reporter/build/reporter.js:57:51) at Generator.next () at /Users/208821/Projects/np-cooking/api/test/e2e/node_modules/wdio-reportportal-reporter/build/reporter.js:7:71 at new Promise () at __awaiter (/Users/208821/Projects/np-cooking/api/test/e2e/node_modules/wdio-reportportal-reporter/build/reporter.js:3:12) at Function.waitLaunchFinished (/Users/208821/Projects/np-cooking/api/test/e2e/node_modules/wdio-reportportal-reporter/build/reporter.js:55:16) at Object.onComplete (/Users/208821/Projects/np-cooking/api/test/e2e/wdio.conf.js:395:20) at Launcher._callee$ (/Users/208821/Projects/np-cooking/api/test/e2e/node_modules/webdriverio/build/lib/launcher.js:366:47) at tryCatch (/Users/208821/Projects/np-cooking/api/test/e2e/node_modules/regenerator-runtime/runtime.js:62:40) at Generator.invoke [as _invoke] (/Users/208821/Projects/np-cooking/api/test/e2e/node_modules/regenerator-runtime/runtime.js:296:22) at Generator.prototype.(anonymous function) [as next] (/Users/208821/Projects/np-cooking/api/test/e2e/node_modules/regenerator-runtime/runtime.js:114:21) at step (/Users/208821/Projects/np-cooking/api/test/e2e/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30) at /Users/208821/Projects/np-cooking/api/test/e2e/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13

Originally posted by @igerasimov23 in https://github.com/BorisOsipov/wdio-reportportal-reporter/issues/1#issuecomment-454532733

BorisOsipov commented 5 years ago

@igerasimov23 the error appears because rp reporter isn't initialized properly cuz it is not enabled. Do you agree that I need check it in reporter.waitLaunchFinished() to avoid this?

BorisOsipov commented 5 years ago

btw I believe error doesn't appear if you will use https://github.com/BorisOsipov/wdio-reportportal-service

igerasimov23 commented 5 years ago

I was trying to use initially https://github.com/BorisOsipov/wdio-reportportal-service but RP never finished active sessions for me. I added as you showed in docs:

const RpService = require("wdio-reportportal-service"); //how much time will wait till launch finishes. default 5000 ms const rpService = new RpService(5000);

and services: [rpService] Am I missing here something?

igerasimov23 commented 5 years ago

@igerasimov23 the error appears because rp reporter isn't initialized properly cuz it is not enabled. Do you agree that I need check it in reporter.waitLaunchFinished() to avoid this?

This error looks like appears only in new method reporter.waitLaunchFinished(). as it works fine with old methods such as reporter.sendLogToTest(test, 'info', passMsg) when 'reportportal' disabled in wdio conf

BorisOsipov commented 5 years ago

I was trying to use initially BorisOsipov/wdio-reportportal-service but RP never finished active sessions for me.

I've tested this on my projects and it works fine. I will have a look deeper to find why the issue appears. One question, doesn't you interrupt tests by ctrl+c? In such a case launch isn't finish in any way AFAIK and waiting is useless(it is another thing to improve as I think)

Also your wdio config will help to test it, please share if you can. Thanks in advance.

igerasimov23 commented 5 years ago

I don't interrupt suite during execution. I used following config and rpService does not complete suite:

const util = require('./utils');
const globals = require('./globals');

const reporter = require('wdio-reportportal-reporter');
const RpService = require("wdio-reportportal-service");
//how much time will wait till launch finishes. default 5000 ms
const rpService = new RpService(10000);

const chai = require('chai');
const assertArrays = require('chai-arrays');
const assertions = require('./customCommands/assertions');

exports.config = {
  host: util.setHost(),
  port: 4444,
  path: '/wd/hub',

  sync: true,
  //
  // Level of logging verbosity: silent | verbose | command | data | result | error
  logLevel: 'data',
  //
  // Enables colors for log output.
  coloredLogs: true,
  //
  // Warns when a deprecated command is used
  deprecationWarnings: true,
  bail: 0,
  //
  baseUrl: util.setUrl(),
  //
  // Default timeout for all waitFor* commands.
  waitforTimeout: globals.baseConfig.waitForTimeout,

  // Default timeout in milliseconds for request
  // if Selenium Grid doesn't send response
  connectionRetryTimeout: process.env.CONNECTRETRYTIMEOUT || 90000,
  //
  // Default request retries count
  connectionRetryCount: 3,

  framework: 'mocha',
  maxInstances: process.env.PARALLELTHREADS || 20,

  capabilities: [
    {
      userCred: globals.userCredArray.cred9,
      version: '',
      browserName: 'chrome',

      specs: [
        './test/features/footer/test-footer.js'
      ],
    }
  ],

  services: [ 'selenium-standalone', rpService],
  reporters: ['reportportal'],
  reporterOptions: {
    reportportal: {
      rpConfig: {
        token: process.env.RP_UUID,
        endpoint: 'https://testreportingsystem.nyt.net/api/v1',
        launch: process.env.JOB_NAME,
        project: 'cooking',
        mode: 'DEFAULT',
        debug: false

      },
      enableSeleniumCommandReporting: true,
      enableScreenshotsReporting: false,
      seleniumCommandsLogLevel: 'debug',
      screenshotsLogLevel: 'info',
      enableRetriesWorkaround: true,
      parseTagsFromTestTitle: true,
    }
  },

  mochaOpts: {
    timeout: process.env.MOCHATIMEOUT || 900000,
    ui: 'bdd',
    grep: process.env.npm_config_grep,
    compilers: ['js:babel-register'],
  },

  beforeSession: function (config, capabilities, specs) {
    //runs block for every capability
    exports.userCred = capabilities.userCred;
    // get sessions and user for parallel in the future

  },

  before: function () {
    chai.config.includeStack = true;
    global.expect = chai.expect;
    global.AssertionError = chai.AssertionError;
    global.Assertion = chai.Assertion;
    global.assert = assertions;

    let options = {defaultWait: 5000};
    let chaiWebdriver = require('chai-webdriverio').default;
    chai.use(chaiWebdriver(browser, options));
    chai.use(assertArrays);

  },

  beforeSuite: function (suite) {

    //setting viewport size
    util.setViewportSize();
  },

  afterTest: function (test) {
    // logging Pass or Fail for test
    if (test.passed) {
      let passMsg = `******* TEST '${test.title}' PASSED ******* `;
      console.log('info', passMsg);
      reporter.sendLogToTest(test, 'info', passMsg)
    } else {
      let failMsg = `******* TEST '${test.title}' FAILED ******* `;
      console.log(failMsg);
      reporter.sendLogToTest(test, 'info', failMsg);
      const screenshot =  browser.saveScreenshot();
      reporter.sendFileToTest(test, 'info', `${test.title}.png`, screenshot);
    }

  },
};

Let me know what you think

BorisOsipov commented 5 years ago

Replace reporters: ['reportportal'], => reporters: [reporter],

igerasimov23 commented 5 years ago

Thank you. works as expected when using rpService

BorisOsipov commented 5 years ago

works as expected when using rpService

@igerasimov23 Nice! Btw I will fix initial issue a bit later.