Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reports are wrong on parallel (sharded) tests #85

Open
jdmwood opened this issue Mar 29, 2019 · 1 comment
Open

Reports are wrong on parallel (sharded) tests #85

jdmwood opened this issue Mar 29, 2019 · 1 comment

Comments

@jdmwood
Copy link

jdmwood commented Mar 29, 2019

Bug report

  • Your protractor configuration file
exports.config = {
  multiCapabilities: [
    {
      shardTestFiles: true,
      maxInstances: 2,
      browserName: 'chrome',
    }
  ],

  specs: [
    '../test/screenshottest/**/*.js'
  ],

  // Default URL to be passed to Protractor
  //baseUrl: 'http://localhost:3000',

  // Framework to be used by Protractor
  framework: 'jasmine2',

  plugins: [{
    package: 'protractor-screenshoter-plugin',
    screenshotPath: './REPORTS/e2e',
    screenshotOnExpect: 'failure+success',
    screenshotOnSpec: 'none',
    withLogs: true,
    writeReportFreq: 'asap',
    imageToAscii: 'none',
    clearFoldersBeforeTest: true
  }],

  // Setup
  onPrepare: () => {
    browser.waitForAngularEnabled(false);

    // returning the promise makes protractor wait for the reporter config before executing tests
    return global.browser.getProcessedConfig().then(function(config) {
      //it is ok to be empty
    });
  }
};
  • Protractor Version: tested in 5.40 and 6.0.0
  • Browser(s): Chrome 73.0.3683.86
  • Node Version: 11.5.0
  • Angular Version: N/A
  • Operating System and Version: MacOS 10.14.2
  • A relevant example test: See below
  • Output from running the test

The report shows the wrong number of tests - it shows whichever tests were run in one of the browser instances

  • Steps to reproduce the bug
  1. Unzip the Zip
  2. cd into the folder
  3. npm install && npm test
  4. Open up REPORTS/e2e/index.html
  5. It should show all 4 test failures, but it only shows 2. E.g.:

Screenshot 2019-03-29 at 12 20 14

It looks like the report gets cleared whenever one of the browser instances closes?

PS: I also tried with later protractor and webdriver-manager (^6.0.0 and webdriver-manager ^13.0.0). You can see this in * protractor-bug-1.zip. Not sure this is working correctly as I get weird errors.

@Galaloo
Copy link

Galaloo commented Apr 9, 2019

I was running into the same issue. Opted to set clearFoldersBeforeTest: false and clear the directory with beforeLaunch. This way the directory is cleaned out when the test run first starts but not with each sharded test.

// config.js
let rmDir = require('../helpers/rmDir');
let path = require('path');
let testReportsDir = path.resolve(__dirname, '../reports/testreports');
...
    beforeLaunch() {
        // clean out the test results directory
        rmDir(testReportsDir);
    },
// rmDir.js
var fs = require('fs');

async function rmDir(dirPath)
{
  try { var files = fs.readdirSync(dirPath); }
  catch(e) { return; }
  if (files.length > 0)
    for (var i = 0; i < files.length; i++) {
      var filePath = dirPath + '/' + files[i];
      if (fs.statSync(filePath).isFile())
        fs.unlinkSync(filePath);
      else
        rmDir(filePath);
    }
  return fs.rmdirSync(dirPath);
};

  module.exports = rmDir;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants