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

jasmineRequire is undefined: Incompatibility with Jasmine 2.x under Protractor? #3

Open
pnstickne opened this issue Nov 19, 2015 · 6 comments

Comments

@pnstickne
Copy link

When running against Jasmine 2.3.2, at call-site of require('jasmine-promises').

Selenium standalone server started at http://10.32.64.38:59425/wd/hub
TypeError: Cannot read property 'interface' of undefined
    at patchInterfaceFn (F:\build\node_modules\jasmine-promises\dist\jasmine-promises.js:71:21)
    at Object.apply (F:\build\node_modules\jasmine-promises\dist\jasmine-promises.js:83:3)
    at Object.<anonymous> (F:\build\node_modules\jasmine-promises\dist\jasmine-promises.js:15:7)
    at Object../patch (F:\build\node_modules\jasmine-promises\dist\jasmine-promises.js:17:4)
    at s (F:\build\node_modules\jasmine-promises\dist\jasmine-promises.js:1:316)
    at e (F:\build\node_modules\jasmine-promises\dist\jasmine-promises.js:1:487)
    at Object.<anonymous> (F:\build\node_modules\jasmine-promises\dist\jasmine-promises.js:1:505)

Versions:

$ npm ls jasmine jasmine-promises protractor
[email protected] F:\build
├── [email protected]
└── [email protected]
└─┬ [email protected]
  └── [email protected]
@pnstickne pnstickne changed the title Incompatibility? Incompatibility with Jasmine 2.3x? Nov 19, 2015
@pnstickne pnstickne changed the title Incompatibility with Jasmine 2.3x? jasmineRequire is undefined: Incompatibility with Jasmine 2.x under Protractor? Nov 19, 2015
@pnstickne
Copy link
Author

My current roundabout solution, run inside onPrepare of the Protractor configuration, which shims (what I believe to be) the jasmineRequire object into the global scope used by jasmine-promise:

        if (!global.jasmineRequire) {
            // jasmine 2 and jasmine promises have differing ideas on what to do inside protractor/node
            var jasmineRequire = require('jasmine-core');
            if (typeof jasmineRequire.interface !== 'function') {
                throw "not able to load real jasmineRequire"
            }
            global.jasmineRequire = jasmineRequire;
        }
        require('jasmine-promises');

The throw is there to hopefully detect if/when this changes on jasmine's side..

@matthewjh
Copy link
Owner

Thanks @pnstickne! I didn't test it with protractor. I have some time to take a look at this either tonight or tomorrow. =)

@massimocode
Copy link

@matthewjh hey, did you get a chance to look at this? I just experienced the same issue.

@matthewjh
Copy link
Owner

matthewjh commented Sep 19, 2016

Hi @massimocode,

Yes, I did, and the fix will be in the version being released today or tomorrow. :)

@matthewjh matthewjh reopened this Sep 19, 2016
@putermancer
Copy link

I encountered this issue as well using jasmine via grunt-jasmine-nodejs. The above workaround seems to be working great for now, inside a helper file loaded before the specs.

@matippetts
Copy link

Hey, @matthewjh -- Cool lib. I just thought I'd mention, when I was evaluating this today, I found that the hack described here also works for Node (v6.5.0). Maybe that will help with resolving both issues (this and #8 ).

A little detail: I'm developing an Electron app, and using Jasmine in combination with Spectron, which -- like Protractor -- is WebDriver under the hood. Spectron doesn't crank up until my test is already executing beforeEach(), so Jasmine itself is running under Node. I've tried this fix and the "mock object" solution proposed under #8 . Both worked for me, but presumably this would be more robust. (Or not? I just met Jasmine for the first time yesterday, so idk.)

I'm not actually using this package going forward, because jasmine-es6 is a better fit for me. But I was really very pleased when I found this earlier today. Eventually I got done() working properly in 'plain' Jasmine, but I would have given up without the confidence your code gave me. So thanks for the boost.

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

5 participants