jasmine-promises
jasmine-promises copied to clipboard
jasmineRequire is undefined: Incompatibility with Jasmine 2.x under Protractor?
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]
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..
Thanks @pnstickne! I didn't test it with protractor. I have some time to take a look at this either tonight or tomorrow. =)
@matthewjh hey, did you get a chance to look at this? I just experienced the same issue.
Hi @massimocode,
Yes, I did, and the fix will be in the version being released today or tomorrow. :)
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.
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.