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

Protractor fails if there were no screenshots taken with captureOnlyFailedSpecs #65

Closed
alexmreis opened this issue Jun 28, 2016 · 2 comments · Fixed by #101
Closed

Protractor fails if there were no screenshots taken with captureOnlyFailedSpecs #65

alexmreis opened this issue Jun 28, 2016 · 2 comments · Fixed by #101

Comments

@alexmreis
Copy link

Version: 0.3.0

Issue

Protractor run fails due to the reporter trying to create a screenshots index file when there are no screenshots taken. caputreOnlyFailedSpecs will always fail in a successful run unless the destination folder is created beforehand.

Expected behaviour

Since the normal behaviour for the reporter is to automatically create the folder, I'd expect it either not to create the file when there is nothing to report, or to create the folder before trying to write to it.

Debug info

Relevant protractor configuration

    HtmlScreenshotReporter = require 'protractor-jasmine2-screenshot-reporter'
    jasmine.getEnv().addReporter new HtmlScreenshotReporter({
      dest: 'reports/e2e/screenshots'
      filename: 'index.html'
      ignoreSkippedSpecs: true,
      reportOnlyFailedSpecs: false
      captureOnlyFailedSpecs: true
    })

Protractor output:

28-Jun-2016 10:48:58    Error: ENOENT: no such file or directory, open 'reports/e2e/screenshots/index.html'
28-Jun-2016 10:48:58        at Error (native)
28-Jun-2016 10:48:58        at Object.fs.openSync (fs.js:549:18)
28-Jun-2016 10:48:58        at Object.fs.writeFileSync (fs.js:1156:15)
28-Jun-2016 10:48:58        at Object.fs.appendFileSync (fs.js:1204:6)
28-Jun-2016 10:48:58        at Jasmine2ScreenShotReporter.jasmineDone (/path/to/project/node_modules/protractor-jasmine2-screenshot-reporter/index.js:482:10)
28-Jun-2016 10:48:58        at dispatch (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1869:28)
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1852:11
28-Jun-2016 10:48:58        at QueueRunner.clearStack (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:605:9)
28-Jun-2016 10:48:58        at QueueRunner.run (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1784:12)
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1801:16
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1745:9
28-Jun-2016 10:48:58        at queueRunnerFactory.onComplete (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:2348:17)
28-Jun-2016 10:48:58        at QueueRunner.clearStack (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:605:9)
28-Jun-2016 10:48:58        at QueueRunner.run (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1784:12)
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1801:16
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1745:9
28-Jun-2016 10:48:58        at queueRunnerFactory.onComplete (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:2348:17)
28-Jun-2016 10:48:58        at QueueRunner.clearStack (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:605:9)
28-Jun-2016 10:48:58        at QueueRunner.run (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1784:12)
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1801:16
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1745:9
28-Jun-2016 10:48:58        at queueRunnerFactory.onComplete (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:2348:17)
28-Jun-2016 10:48:58        at QueueRunner.clearStack (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:605:9)
28-Jun-2016 10:48:58        at QueueRunner.run (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1784:12)
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1801:16
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1745:9
28-Jun-2016 10:48:58        at complete (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:365:9)
28-Jun-2016 10:48:58        at QueueRunner.clearStack (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:605:9)
28-Jun-2016 10:48:58        at QueueRunner.run (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1784:12)
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1801:16
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1745:9
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasminewd2/index.js:18:5
28-Jun-2016 10:48:58        at [object Object].promise.Promise.goog.defineClass.invokeCallback_ (/path/to/project/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1337:14)
28-Jun-2016 10:48:58        at [object Object].promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_.execute_ (/path/to/project/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2776:14)
28-Jun-2016 10:48:58        at [object Object].promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_ (/path/to/project/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2758:21)
28-Jun-2016 10:48:58        at goog.async.run.processWorkQueue (/path/to/project/node_modules/selenium-webdriver/lib/goog/async/run.js:124:15)
28-Jun-2016 10:48:58        at process._tickCallback (node.js:368:9)
28-Jun-2016 10:48:58    [launcher] Process exited with error code 1
@mlison
Copy link
Owner

mlison commented Jul 1, 2016

First of, extra internet points to you sir for the bug report, wish all of them would be like this.

That said, I've tried following configuration with my test suite:

var ScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');

var reporter = new ScreenshotReporter({
  dest: 'reports/e2e/test',
  filename: 'index.html',
  ignoreSkippedSpecs: true,
  reportOnlyFailedSpecs: false,
  captureOnlyFailedSpecs: true
});

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['specs/test-spec.js'],
  baseUrl: 'http://www.google.com/',
  framework: 'jasmine',

  capabilities: {
    browserName: 'chrome'
  },

  // Setup the report before any tests start
  beforeLaunch: function() {
    return new Promise(function(resolve){
      reporter.beforeLaunch(resolve);
    });
  },

  onPrepare: function() {
    jasmine.getEnv().addReporter(reporter);
  },

  // Close the report after all tests finish
  afterLaunch: function(exitCode) {
    return new Promise(function(resolve){
      reporter.afterLaunch(resolve.bind(this, exitCode));
    });
  }
};

I've tried multiple combinations of failing and successful tests, but at worst the result is a directory with only index.html, where there's 0 specs / screenshots to be reported.

Could you please elaborate on your setup? Maybe there's something specific in your suites that I need to replicate to get the same result. What environment are you running in? What's the node version?

@kaqqao
Copy link

kaqqao commented Nov 22, 2016

Having a similar problem with 0.3.2. The directory even gets created but the process still exists with an error. The setup is as simple as it gets:

var htmlReporter = new HtmlScreenshotReporter({
		dest: 'target/reports/html',
		filename: 'report.html',
		reportTitle: "E2E test report",
		pathBuilder: function(currentSpec, suites, browserCapabilities) {
			return browserCapabilities.get('browserName') + '/' + currentSpec.id;
		}
});

ENOENT: no such file or directory, open 'target/reports/html/report.html'

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