Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

ReferenceError: Can't find variable: Promise #12401

Closed
liliakai opened this issue Jul 25, 2014 · 45 comments
Closed

ReferenceError: Can't find variable: Promise #12401

liliakai opened this issue Jul 25, 2014 · 45 comments
Assignees

Comments

@liliakai
Copy link

I'm using mocha-phantomjs 3.5.0 (phantomjs 1.9.7). My mocha tests pass in Chrome but phantom gives the error above.

👻

@JamesMGreene
Copy link
Collaborator

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?

@liliakai
Copy link
Author

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.

@piuccio
Copy link

piuccio commented Nov 18, 2014

+1 😄

@Gowiem
Copy link

Gowiem commented Dec 9, 2014

+1

2 similar comments
@gergely-ujvari
Copy link

+1

@Aurifier
Copy link

👍

@zzarcon
Copy link

zzarcon commented Jan 5, 2015

@JamesMGreene some update about this? :)

@zzarcon
Copy link

zzarcon commented Jan 5, 2015

I ended using a simple workaround; adding this Promise Polyfill at the beginning of the tests, hope be util for you!

@JamesMGreene
Copy link
Collaborator

Although the current master isn't quite where we hoped it would be, we are planning to release it as v2.0.0 on January 23rd (?) and work out the remaining kinks from there once we can all shift focus to v2.x.

@JamesMGreene
Copy link
Collaborator

That said: I have not verified that the native Promise API is implemented in master.

@vitallium
Copy link
Collaborator

PhantomJS 2 doesn't have native Promise API.

@fredck
Copy link

fredck commented Feb 20, 2015

+1

Promise is available natively in all modern browsers except IEs (IE12 has it)... it's a must have!

@MrJH
Copy link

MrJH commented Feb 25, 2015

+1

@masi
Copy link

masi commented Mar 21, 2015

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.

@mockdeep
Copy link

Just ran into this. I'll give the polyfill a try.

@masi
Copy link

masi commented Jun 20, 2015

Shims (polyfills) for promises work well.

@danawoodman
Copy link

Any progress on this?

@kawing-chiu
Copy link

Using es6-promise polyfill works for me. But the polyfill must be put into the page's js code, not to the phantomjs script.

justin808 added a commit to shakacode/react-webpack-rails-tutorial that referenced this issue Aug 6, 2015
* 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
justin808 added a commit to shakacode/react-webpack-rails-tutorial that referenced this issue Aug 22, 2015
* 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
@dbaba
Copy link

dbaba commented Sep 30, 2015

+1
es6-promise works for me as well as polyfill though (PhantomJS 2.0.0).

@hbrysiewicz
Copy link

+1

1 similar comment
@dteleguin
Copy link

+1

@floverdevel
Copy link

We had the same problem and choose to inject Babel into our test suite for now.
Our unit tests runs on node.js with jasmine and are therefor ok with Promise.
But our cucumber tests runs into phantom.js and we injected Babel libray to polyfill Promise.

https://babeljs.io/ works great, but maybe to have «native support» of ES6 feature would be even better :)

@jimmywarting
Copy link

@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.
That is why i'm considering switching to SlimerJS to use an up to date Gecko browser. Seems to me that phantomjs is falling behind on the webkits release cycle's 👎

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.
It's like this with samsung phones. Just buy Google's Nexa phone and you know you will be the first to receive an update. Don't have to wait for samsung to wait for next android version so they can update the consumer's phone 3-8 month later or even at all. Instead they just stop maintaining it and announce a new phone called Samsung Galaxy s203 special gold edition v2.0

@floverdevel
Copy link

@jimmywarting i love the comparison with Samsung and the Android update :P

@sickOscar
Copy link

+1

1 similar comment
@msn0
Copy link

msn0 commented Feb 27, 2016

+1

@inaccessible
Copy link

+1

4 similar comments
@AChris07
Copy link

+1

@sygn
Copy link

sygn commented Apr 1, 2016

+1

@msn0
Copy link

msn0 commented Apr 1, 2016

+1

@Radiergummi
Copy link

+1

@jimmywarting
Copy link

Can you stop writing +1 so we don't get useless notifications all the time
Github have introduced reactions. use that instead.

screen shot 2016-04-05 at 15 59 06

@vitallium vitallium added this to the FutureRelease milestone Apr 11, 2016
@vitallium vitallium self-assigned this Apr 11, 2016
@nmors
Copy link

nmors commented Apr 13, 2016

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..

@SourceCode
Copy link

SourceCode commented Apr 22, 2016

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!

@filipalacerda
Copy link

Either es6-promise and promise-polyfill do the trick!
Thank you @dbaba, @zzarcon and @kawing-chiu for the suggestions!

Just need to include one of them in karma.conf.js in files option

es6-promise:
files: ['./node_modules/es6-promise/dist/es6-promise.js']

promise-polyfill:
files: ['./node_modules/promise-polyfill/promise.js']

@ariya
Copy link
Owner

ariya commented Aug 25, 2016

Please track ES6 support in #14506. Thank you!

@ariya ariya closed this as completed Aug 25, 2016
@baipgydx729
Copy link

+1

@NeilJ247
Copy link

NeilJ247 commented Jan 3, 2017

@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.

@Zoheb-hassan
Copy link

There's a phantomjs polyfill that can downloaded via the npm manager, https://www.npmjs.com/package/phantomjs-polyfill this helps resolve the promise error you will encounter

@kid-wumeng
Copy link

@Somebi
Copy link

Somebi commented Sep 24, 2017

+1 :D Get ES6 support faster ffs.

@annelledj
Copy link

annelledj commented Nov 6, 2017

The following in karma.conf.js did not work for me, @filipalacerda
files: ['./node_modules/es6-promise/dist/es6-promise.js']

I had to change it to this to get it to work :)
files: ['./node_modules/es6-promise/dist/es6-promise.auto.js']

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests