Coder Social home page Coder Social logo

Comments (27)

shahata avatar shahata commented on July 21, 2024 1

The solution for this is pretty simple: onPrepare should return the promise and so protractor will wait for the promise to resolve before going on to running the tests:

  framework: 'jasmine2',
  onPrepare: function() {
    var jasmineReporters = require('jasmine-reporters');
    return browser.getProcessedConfig().then(function(config) {
      jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({...}));
    });
  }

from jasmine-reporters.

putermancer avatar putermancer commented on July 21, 2024

Are there any other interesting aspects related to the tests that are failing? For example, fit and/or fdescribe? Last month I discovered problems with our handling of fit and fdescribe and released [email protected] to address them. Since then, I've been successfully using protractor 2.0 with jasmine-reporters 2.0.5 without any issues.

Make sure you are using 2.0.5 of jasmine-reporters and that you've configured protractor with framework: 'jasmine2'. If you're still having problems, share any interesting information about how you are running your specs, your protractor config, environment, etc.

from jasmine-reporters.

chazzlabs avatar chazzlabs commented on July 21, 2024

I'm getting the same error message on Windows 8.1 and in a Jenkins job running on Ubuntu. I'm running my tests using grunt-protractor-runner and grunt-protractor-webdriver.

I'm using "xdescribe" and "xit" to ignore some suites and specs while I clean up the configuration of our test jobs. My suites/specs are setup like this:

   describe('some test suites and specs', function() {

    // Some setup here

    describe('sample suite', function() {
        xit('ignores this spec', function() {
            // ... some expect() calls here
        });

        it('runs this spec', function() {
            // ... some expect() calls here
        });
    });

    xdescribe('ignored suite', function() {
        it('would run if the suite were enabled', function() {
            // ... some expect() calls here
        });
    });

});

When the ignored suites and spec are removed completely, I'm not seeing this error.

from jasmine-reporters.

putermancer avatar putermancer commented on July 21, 2024

What version of jasmine-reporters are you using?

from jasmine-reporters.

chazzlabs avatar chazzlabs commented on July 21, 2024

Using version 2.0.5.

from jasmine-reporters.

chazzlabs avatar chazzlabs commented on July 21, 2024

Rolled back to 2.0.4, and I'm seeing the same issue.

from jasmine-reporters.

putermancer avatar putermancer commented on July 21, 2024

Thanks, I'll take a deeper look in the next couple days.

from jasmine-reporters.

chazzlabs avatar chazzlabs commented on July 21, 2024

@bloveridge My issues were resolved after updating from Node v.0.10.x to v.0.12.2. I should have thought to check my Node version sooner.

I verified this with all tests running and passing, all tests running and failing, and with some tests/suites ignored.

from jasmine-reporters.

MaxiSir avatar MaxiSir commented on July 21, 2024

I have encountered this problem as well.
In my test suite with protractor 2.0 there was raised on exception and the whole jasmine crashes with the exception above.

the structure of e2e test is like:

describe('', function () {
var session = require('...');

beforeEach(function () {
    session.login();
});

afterEach(function (done) {
    session.clearStorage().then(done);
});

describe('preserves state', function () {
    it('test case where it fails', function () {
        throw exception()...
    });
});

});

nodeJs 12.2
OS X,
protractor 2.0
jasmine reporters 2.0.5

from jasmine-reporters.

xuxiankun avatar xuxiankun commented on July 21, 2024

i faced the same issue after upgrading to protractor 2.0.

from jasmine-reporters.

pgconreaux avatar pgconreaux commented on July 21, 2024

I have been able to reproduce this error with the following in protractor.conf.js:

  framework: 'jasmine2',
  onPrepare: function() {
    var jasmineReporters = require('jasmine-reporters');
    browser.getProcessedConfig().then(function(config) {
      console.log('Executing capability', config.capabilities);
      jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
        consolidateAll: true,
        filePrefix: 'xmloutput',
        savePath: 'testresults'
      }));
    });
  }

Here's the full stacktrace:

/Users/pgconreaux/WebstormProjects/E2E/node_modules/jasmine-reporters/src/junit_reporter.js:152
            if (isFailed(spec)) { spec._suite._failures++; }
                                             ^
TypeError: Cannot read property '_failures' of undefined
    at [object Object].self.specDone (/Users/pgconreaux/WebstormProjects/E2E/node_modules/jasmine-reporters/src/junit_reporter.js:152:46)
    at dispatch (/Users/pgconreaux/WebstormProjects/E2E/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1869:28)
    at ReportDispatcher.specDone (/Users/pgconreaux/WebstormProjects/E2E/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1852:11)
    at Spec.specResultCallback [as resultCallback] (/Users/pgconreaux/WebstormProjects/E2E/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:813:18)
    at complete (/Users/pgconreaux/WebstormProjects/E2E/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:362:12)
    at QueueRunner.clearStack (/Users/pgconreaux/WebstormProjects/E2E/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:605:9)
    at QueueRunner.run (/Users/pgconreaux/WebstormProjects/E2E/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1784:12)
    at /Users/pgconreaux/WebstormProjects/E2E/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1801:16
    at /Users/pgconreaux/WebstormProjects/E2E/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1745:9
    at Function.next.fail (/Users/pgconreaux/WebstormProjects/E2E/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1807:9)

Environment:
OSX: 10.10.3
protractor: 2.1.0
node: 0.12.0
jasmine-reporters: 2.0.6

from jasmine-reporters.

irrenhaus avatar irrenhaus commented on July 21, 2024

Same here, protractor version 2.1.0, jasmine-reporters 2.0.6.

Problem seems to occur if the spec has an error in it causing an exception to be thrown.
For whatever reason Jasmine 2 calls suiteStarted / specStarted only after the spec itself has run. This causes the error because if an exception is thrown in the spec, suiteStarted & specStarted are never called which causes suite._specs & currentSuite to be undefined. For the same reason spec._suite is not defined (as it is defined in specStarted).
However, specDone is called even after an exception. This method then tries to access spec._suite and throws the exception given by the others above because, well, spec._suite is undefined.

I'm not sure what the correct way to fix this would be, simply & easy fix (which, maybe, is not the way this module should work) would be to replace
if (isSkipped(spec)) { spec._suite._skipped++; }
if (isDisabled(spec)) { spec._suite._disabled++; }
if (isFailed(spec)) { spec._suite._failures++; }
with
if (spec._suite && isSkipped(spec)) { spec._suite._skipped++; }
if (spec._suite && isDisabled(spec)) { spec._suite._disabled++; }
if (spec._suite && isFailed(spec)) { spec._suite._failures++; }

@larrymyers Let me know if I can help with some further debugging.

EDIT: See irrenhaus@dc6b837 for a better (but still possibly ugly) quick fix.

from jasmine-reporters.

c3s4r avatar c3s4r commented on July 21, 2024

Probably the error is related to configuring the reports on the getProcessedConfig promise.

In my specific scenario, this code produces the error:

  onPrepare: function() {
    var jasmineReporters = require('jasmine-reporters');
    browser.getProcessedConfig().then(function(config){
      var capabilities = config.capabilities;
      var prefix = capabilities.browserName + '-';
      jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
        savePath: './test-results/e2e',
        filePrefix: prefix
      }));
    });
  }

While this code works fine:

  onPrepare: function() {
    var jasmineReporters = require('jasmine-reporters');
    var prefix = process.pid + '-';
    jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter(
      savePath: './test-results/e2e',
      filePrefix: prefix
    }));
  }

from jasmine-reporters.

reppners avatar reppners commented on July 21, 2024

+1 I've got exactly the same issue as c3s4r

Is something not initialized right due to the async nature of the promise?

from jasmine-reporters.

putermancer avatar putermancer commented on July 21, 2024

Thanks for the details so far and sorry it has taken so long to get to this, hopefully I will get a chance to look into this more in another week or so.

From what I can tell, protractor's asynchronous getProcessedConfig logic is doing non-standard things with jasmine that the framework itself does not plan for and have support for.

For clarification, does the error only occur when using getProcessedConfig and then an exception is thrown inside a test? Or anytime you try to use fit/fdescribe? or when using xit/xdescribe? or something else? The reports kind of seem all over the place right now.

from jasmine-reporters.

c3s4r avatar c3s4r commented on July 21, 2024

@bloveridge: The issue happens when the reporter is added using the getProcessedConfig promise. It doesn't matter if you are using or not using fit/fdescribe or xit/xdescribe.

from jasmine-reporters.

putermancer avatar putermancer commented on July 21, 2024

@c3s4r It happens all the time when using getProcessedConfig, or only when an exception is encountered? I'm thinking specifically about this earlier statement: "seems to occur if the spec has an error in it causing an exception to be thrown."

from jasmine-reporters.

c3s4r avatar c3s4r commented on July 21, 2024

@bloveridge you're right, it doesn't happen when all tests pass. It only happens if at least one test fails.

from jasmine-reporters.

reppners avatar reppners commented on July 21, 2024

@bloveridge while testing the changes made in my pull request I saw that the "fallback" spec names focused specs were used in my result file name. Maybe this gives you a hint where things start to go wrong?

from jasmine-reporters.

putermancer avatar putermancer commented on July 21, 2024

Yeah, I guess that makes sense. Before deciding on the right fix for this, first I need to try and discover what Jasmine is doing under the hood when run by protractor in this way -- if some reporter methods are being called twice, others not, sharing data between different instances, etc.

Though I would not expect any data to be bleeding across into different instances, since each instance creates its own closure variables inside the constructor. I can only surmise that something in the way protractor is using jasmine is causing it to behave abnormally when calling reporter methods.

Definitely needs more investigation. sigh

from jasmine-reporters.

shahata avatar shahata commented on July 21, 2024

@bloveridge It seems to me that the cause for this is simply the fact the reporter is added after the tests have already started to run. By the time getProcessedConfig() promise is resolved, the specStarted had already happened and so when specDone is called, it fails to find spec._suite since the reporter never got the specStarted and never assigned spec._suite.

from jasmine-reporters.

reppners avatar reppners commented on July 21, 2024

@shahata
You're right, returning the promise fixes it. I changed the README.md example in my pull-request.

from jasmine-reporters.

putermancer avatar putermancer commented on July 21, 2024

@shahata Thanks for that, I just finished reading the protractor release notes based on your comment and planned to look into returning the getProcessedConfig promise this morning. Thanks @reppners for confirming it works.

I'll close this issue once the README has been updated.

from jasmine-reporters.

putermancer avatar putermancer commented on July 21, 2024

The README has been updated to show how to make Protractor wait until getProcessedConfig() has happened and how to get unique output files for each capability.

2.0.7 has also been released, which adds a new modifySuiteName option to JUnitXmlReporter which will help you to get unique suite names for each capability as well.

Thanks everyone for submitting reports, info, and patches.

from jasmine-reporters.

Saurabh06 avatar Saurabh06 commented on July 21, 2024

@bloveridge, I am getting error when using with protractor 3.1.1

Selenium standalone server started at http://10.30.60.241:54685/wd/hub
Started
�[31mF�[0m[launcher] Process exited with error code 1

C:\Users\username\AppData\Roaming\npm\node_modules\protractor-jasmine2-html-reporter\index.js:146
if (isFailed(spec)) { spec._suite._failures++; }
^
TypeError: Cannot read property '_failures' of undefined
at Jasmine2HTMLReporter.self.specDone (C:\Users\username\AppData\Roaming\npm\node_modules\protractor-jasmine2-html-reporter\index.js:146:42)
at dispatch (D:\worskspace_callcenter\ProtractorDemo\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1966:28)
at ReportDispatcher.specDone (D:\worskspace_callcenter\ProtractorDemo\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1949:11)
at Spec.specResultCallback as resultCallback
at complete (D:\worskspace_callcenter\ProtractorDemo\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:368:12)
at QueueRunner.clearStack (D:\worskspace_callcenter\ProtractorDemo\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:660:9)
at QueueRunner.run (D:\worskspace_callcenter\ProtractorDemo\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1881:12)
at D:\worskspace_callcenter\ProtractorDemo\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1898:16
at D:\worskspace_callcenter\ProtractorDemo\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1842:9
at D:\worskspace_callcenter\ProtractorDemo\node_modules\protractor\node_modules\jasminewd2\index.js:18:5

from jasmine-reporters.

nikravi avatar nikravi commented on July 21, 2024

@Saurabh06 check this #94 (comment)

from jasmine-reporters.

Saurabh06 avatar Saurabh06 commented on July 21, 2024

Still problem is not resolved.
I am using "protractor-jasmine2-html-reporter" with Jasmine2 Framework in conf.js
onPrepare: function() {
var capsPromise = browser.getProcessedConfig();
capsPromise.then(function(caps){
var browserName = caps.capabilities.browserName.toUpperCase();
var browserVersion = caps.capabilities.browser_version;
var platform = process.platform;
var prePendStr=browserName+""+browserVersion+""+platform;
browser.manage().timeouts().pageLoadTimeout(600000),
browser.manage().timeouts().implicitlyWait(300000),
jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({
savePath: _dirname+'/../TestOutput/Automation_reports'+timeStamp+'/',
takeScreenshotsOnlyOnFailures: true,
screenshotsFolder: './screenshots',
filePrefix: prePendStr+'report'
}));});
}
getting error:
image

from jasmine-reporters.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.