-
Notifications
You must be signed in to change notification settings - Fork 5.8k
ReferenceError: Can't find variable: Promise #12401
Comments
Native Promises are an extremely recent addition (I'm not even sure if it's officially standard yet), so this is not surprising whatsoever. Are there native Promises in your code/tests, or is the error coming from mocha-phantomjs? |
They're in my code. Any plan to add support in the near future? Or do you know of any other headless browsers that have implemented them? I suppose I'll have to shim them into my test page otherwise. Also, (and this is a separate issue, but) same question regarding support for Array-like objects in Function.prototype.apply. |
+1 😄 |
+1 |
2 similar comments
+1 |
👍 |
@JamesMGreene some update about this? :) |
I ended using a simple workaround; adding this Promise Polyfill at the beginning of the tests, hope be util for you! |
Although the current |
That said: I have not verified that the native |
PhantomJS 2 doesn't have native |
+1 Promise is available natively in all modern browsers except IEs (IE12 has it)... it's a must have! |
+1 |
Node has Promises, ECMA6 will have them and notably SilmerJS has them already. The SlimerJS devs had the idea to make webpage.open to return a Promise which is IMHO a great improvement to the API. |
Just ran into this. I'll give the polyfill a try. |
Shims (polyfills) for promises work well. |
Any progress on this? |
Using es6-promise polyfill works for me. But the polyfill must be put into the page's js code, not to the phantomjs script. |
* For the phantomjs issue: ariya/phantomjs#12401 * Still getting a warning iterable.length has been deprecated, use iterable.size or iterable.count(). This warning will become a silent error in a future version. Error: at :4602
* For the phantomjs issue: ariya/phantomjs#12401 * Still getting a warning iterable.length has been deprecated, use iterable.size or iterable.count(). This warning will become a silent error in a future version. Error: at :4602
+1 |
+1 |
1 similar comment
+1 |
We had the same problem and choose to inject Babel into our test suite for now. https://babeljs.io/ works great, but maybe to have «native support» of ES6 feature would be even better :) |
@floverdevel That is what i have been doing. Would agree that it would be cool to have native support. but there is things that not even a precompiler can solve... like if the website i'm navigate to uses arrow function, generators and what not. Would love phantomjs if it used Blinks engine and had auto update as well. Having to wait for a third party to update their product and update their dependency is urck. |
@jimmywarting i love the comparison with Samsung and the Android update :P |
+1 |
1 similar comment
+1 |
+1 |
4 similar comments
+1 |
+1 |
+1 |
+1 |
Running into this issue also. including https://raw.githubusercontent.com/stefanpenner/es6-promise/master/dist/es6-promise.min.js does the job. Would be great to support es6 in pjs though.. |
I have an open issue on StackOverflow regarding promise support in PhantomJS and CasperJS. We ended up moving to SlimerJS until the support for native promises is added to PhantomJS. The issue is here: http://stackoverflow.com/questions/36603470/casperjs-phantomjs-es6-promise-polyfill for others facing this same issue. No resolution has been posted on how to handle this in the client and I was unable to inject anything into phantom that would handle the support for whatever reason. If someone has a resolution it would be greatly appreciated otherwise I look forward to the native promise support in Phantom when it becomes available. Thank you for the hard work! |
Either es6-promise and promise-polyfill do the trick! Just need to include one of them in karma.conf.js in es6-promise: promise-polyfill: |
Please track ES6 support in #14506. Thank you! |
+1 |
@dbaba how did you go about adding the Promise polyfill? Are you adding it to original source webpage or injecting it somehow using PhantomJS? Thanks in advance. |
There's a phantomjs polyfill that can downloaded via the npm manager, |
@Zoheb-hassan the page of https://github.com/ariya/phantomjs/issues/link is 404 |
+1 :D Get ES6 support faster ffs. |
The following in karma.conf.js did not work for me, @filipalacerda I had to change it to this to get it to work :) |
I'm using mocha-phantomjs 3.5.0 (phantomjs 1.9.7). My mocha tests pass in Chrome but phantom gives the error above.
👻
The text was updated successfully, but these errors were encountered: