webdriverio-community / wdio-html-reporter

Fork of wdio-html-format-reporter
MIT License
18 stars 27 forks source link

TypeError: Cannot read property 'createReport' of undefined (while generating master report) #26

Closed drptbl closed 4 years ago

drptbl commented 4 years ago
 (node:78) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'createReport' of undefined
     at /home/node/app/node_modules/xxx/e2e-fwk/conf/e2e.base.conf.js:361:37
     at Object.onComplete (/home/node/app/node_modules/xxx/e2e-fwk/conf/e2e.base.conf.js:370:7)
     at Promise.all.onCompleteHook.map (/home/node/app/node_modules/@wdio/cli/build/utils.js:82:13)
     at Array.map (<anonymous>)
     at runOnCompleteHook (/home/node/app/node_modules/@wdio/cli/build/utils.js:80:37)
     at Launcher.run (/home/node/app/node_modules/@wdio/cli/build/launcher.js:83:69)
     at process._tickCallback (internal/process/next_tick.js:68:7)
 (node:78) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
 (node:78) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
 error Command failed with exit code 1.

^ Getting following error after doing step-by-step setup for master report from README. Using wdio@6 & node 10.

rpii commented 4 years ago

createReport doesnt require any parameters anymore. look the the typescript bindings

Rich

On Fri, Apr 17, 2020 at 6:29 AM Jakub Mucha notifications@github.com wrote:

These changes fixed it for me:

onPrepare: (config, capabilities) => { global.reportAggregator = new ReportAggregator({ outputDir: ${reportsPath}/html-report/, filename: 'master-report.html', reportTitle: Master Report for ${process.env.REVIEW_URL}, browserName: browser.capabilities.browserName }).clean(); },

onComplete: (exitCode, config, capabilities, results) => { global.reportAggregator.createReport({ config: config, capabilities: capabilities, results: results }); },

Cheers.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rpii/wdio-html-reporter/issues/26#issuecomment-615244176, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEABIELVBICXHJRFSQBKSJLRNBKQXANCNFSM4MKXRB6Q .

drptbl commented 4 years ago

My main point was that if someone follow the README, there is no way to make it work. It's outdated.

Same here: https://webdriver.io/docs/rpii-wdio-html-reporter.html

rpii commented 4 years ago

I thought I had updated that. Sorry about that... its updated now in git and I will publish it soon.

On Sat, Apr 18, 2020 at 6:11 AM Jakub Mucha notifications@github.com wrote:

Closed #26 https://github.com/rpii/wdio-html-reporter/issues/26.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rpii/wdio-html-reporter/issues/26#event-3247352957, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEABIELYVL22LJYEVE2T4DTRNGRDZANCNFSM4MKXRB6Q .

rpii commented 4 years ago

I created an issue for the cucumber test. Is not working

On Sat, Apr 18, 2020 at 6:11 AM Jakub Mucha notifications@github.com wrote:

Closed #26 https://github.com/rpii/wdio-html-reporter/issues/26.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rpii/wdio-html-reporter/issues/26#event-3247352957, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEABIELYVL22LJYEVE2T4DTRNGRDZANCNFSM4MKXRB6Q .

argirovatina commented 4 years ago

I am still facing this issue.

const {ReportAggregator, HtmlReporter} = require("@rpii/wdio-html-reporter");

exports.config = {
  // debug: true,
  baseUrl: 'test.com',
  specs: [
    "./e2e/tests/**/**-spec.ts"
  ],
  runner: 'local',
  port: 9515,
  path: '/',
  services: [
    ['chromedriver', {
      args: ['--silent'] //
    }]
  ],
  capabilities: [{
    maxInstances: 1,
    browserName: 'chrome',
    'goog:chromeOptions': {
      args: ["--headless, --disable-gpu", "no-sandbox", "incognito", "--window-size=1920,1500"]
    }
  }],
  outputDir: "./e2e/logs",
  waitForTimeout: 1000,
  coloredLogs: true,
  screenshotOnReject: {
    connectionRetryTimeout: 30000,
    connectionRetryCount: 0
  },
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    helpers: [require.resolve('@babel/register')]
  },
  reporters: [
    'spec',
    ['allure', {
      outputDir: './e2e/test-reports/allure-results',
      disableWebdriverStepsReporting: true,
      disableWebdriverScreenshotsReporting: true,
    }]
  ],
  reporterOptions: {
    allure: {
      outputDir: './e2e/test-reports/allure-results'
    }
      [HtmlReporter, {
      outputDir: './e2e/test-reports/',
      filename: 'report.html',
      reportTitle: 'Test Report Title',
      showInBrowser: true,
      useOnAfterCommandForScreenshot: false,
    }
      ]
  },
  beforeSession: function (config, capabilities, specs) {
    require('ts-node').register({
      project: require('path').join(__dirname, './tsconfig.e2e.json')
    })
  },

  onPrepare: function (config, capabilities) {
    let reportAggregator = new ReportAggregator({
      outputDir: './e2e/test-reports/',
      filename: 'master-report.html',
      reportTitle: 'Master Report',
      browserName: browser.capabilities.browserName,
template.hbs')
    });
    reportAggregator.clean();
    global.reportAggregator = reportAggregator;
  },

  afterTest: function (test) {
    const path = require('path');
    const moment = require('moment');

    if (test.passed) {
      return;
    }
    const timestamp = moment().format('YYYYMMDD-HHmmss.SSS');
    const filepath = path.join('./e2e/test-reports/screenshots/', timestamp + '.png');
    browser.saveScreenshot(filepath);
    process.emit('test:screenshot', filepath);
    browser.reloadSession();
  },

  onComplete: function (exitCode, config, capabilities, results) {
    (async () => {
      await global.reportAggregator.createReport();
    })();
  }
}

`

chandrasekhar11 commented 4 years ago

I am still facing this issue.

const {ReportAggregator, HtmlReporter} = require("@rpii/wdio-html-reporter");

exports.config = {
  // debug: true,
  baseUrl: 'test.com',
  specs: [
    "./e2e/tests/**/**-spec.ts"
  ],
  runner: 'local',
  port: 9515,
  path: '/',
  services: [
    ['chromedriver', {
      args: ['--silent'] //
    }]
  ],
  capabilities: [{
    maxInstances: 1,
    browserName: 'chrome',
    'goog:chromeOptions': {
      args: ["--headless, --disable-gpu", "no-sandbox", "incognito", "--window-size=1920,1500"]
    }
  }],
  outputDir: "./e2e/logs",
  waitForTimeout: 1000,
  coloredLogs: true,
  screenshotOnReject: {
    connectionRetryTimeout: 30000,
    connectionRetryCount: 0
  },
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    helpers: [require.resolve('@babel/register')]
  },
  reporters: [
    'spec',
    ['allure', {
      outputDir: './e2e/test-reports/allure-results',
      disableWebdriverStepsReporting: true,
      disableWebdriverScreenshotsReporting: true,
    }]
  ],
  reporterOptions: {
    allure: {
      outputDir: './e2e/test-reports/allure-results'
    }
      [HtmlReporter, {
      outputDir: './e2e/test-reports/',
      filename: 'report.html',
      reportTitle: 'Test Report Title',
      showInBrowser: true,
      useOnAfterCommandForScreenshot: false,
    }
      ]
  },
  beforeSession: function (config, capabilities, specs) {
    require('ts-node').register({
      project: require('path').join(__dirname, './tsconfig.e2e.json')
    })
  },

  onPrepare: function (config, capabilities) {
    let reportAggregator = new ReportAggregator({
      outputDir: './e2e/test-reports/',
      filename: 'master-report.html',
      reportTitle: 'Master Report',
      browserName: browser.capabilities.browserName,
template.hbs')
    });
    reportAggregator.clean();
    global.reportAggregator = reportAggregator;
  },

  afterTest: function (test) {
    const path = require('path');
    const moment = require('moment');

    if (test.passed) {
      return;
    }
    const timestamp = moment().format('YYYYMMDD-HHmmss.SSS');
    const filepath = path.join('./e2e/test-reports/screenshots/', timestamp + '.png');
    browser.saveScreenshot(filepath);
    process.emit('test:screenshot', filepath);
    browser.reloadSession();
  },

  onComplete: function (exitCode, config, capabilities, results) {
    (async () => {
      await global.reportAggregator.createReport();
    })();
  }
}

`

Is this resolved ? whats the solution ?

juliogomezv commented 3 years ago

Does someone solve this error?

rpii commented 3 years ago

The solution is what I have stated. You need the code in the onPrepare function... set a breakpoint there and make sure the global object is created...

onPrepare: function (config, capabilities) { let reportAggregator = new ReportAggregator({ outputDir: './e2e/test-reports/', filename: 'master-report.html', reportTitle: 'Master Report', browserName: browser.capabilities.browserName, template.hbs') }); reportAggregator.clean(); global.reportAggregator = reportAggregator; },

On Tue, Oct 13, 2020 at 2:27 PM juliogomezv notifications@github.com wrote:

Does someone solve this error?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rpii/wdio-html-reporter/issues/26#issuecomment-708018575, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEABIEJH5ZVX5L3SNOL2G4DSKTAZHANCNFSM4MKXRB6Q .