This repository has been archived by the owner. It is now read-only.

ReferenceError: Can't find variable: Promise #12401

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

Comments

Projects
None yet
@liliakai

liliakai commented Jul 25, 2014

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

This comment has been minimized.

Show comment
Hide comment
@JamesMGreene

JamesMGreene Jul 25, 2014

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?

Collaborator

JamesMGreene commented Jul 25, 2014

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

This comment has been minimized.

Show comment
Hide comment
@liliakai

liliakai Jul 25, 2014

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.

liliakai commented Jul 25, 2014

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

This comment has been minimized.

Show comment
Hide comment
@piuccio

piuccio Nov 18, 2014

+1 馃槃

piuccio commented Nov 18, 2014

+1 馃槃

@Gowiem

This comment has been minimized.

Show comment
Hide comment
@Gowiem

Gowiem commented Dec 9, 2014

+1

@gergely-ujvari

This comment has been minimized.

Show comment
Hide comment

gergely-ujvari commented Dec 10, 2014

+1

@Aurifier

This comment has been minimized.

Show comment
Hide comment
@Aurifier

Aurifier commented Dec 18, 2014

馃憤

@zzarcon

This comment has been minimized.

Show comment
Hide comment
@zzarcon

zzarcon Jan 5, 2015

@JamesMGreene some update about this? :)

zzarcon commented Jan 5, 2015

@JamesMGreene some update about this? :)

@zzarcon

This comment has been minimized.

Show comment
Hide comment
@zzarcon

zzarcon Jan 5, 2015

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

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

This comment has been minimized.

Show comment
Hide comment
@JamesMGreene

JamesMGreene Jan 5, 2015

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.

Collaborator

JamesMGreene commented Jan 5, 2015

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

This comment has been minimized.

Show comment
Hide comment
@JamesMGreene

JamesMGreene Jan 5, 2015

Collaborator

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

Collaborator

JamesMGreene commented Jan 5, 2015

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

@Vitallium

This comment has been minimized.

Show comment
Hide comment
@Vitallium

Vitallium Jan 5, 2015

Collaborator

PhantomJS 2 doesn't have native Promise API.

Collaborator

Vitallium commented Jan 5, 2015

PhantomJS 2 doesn't have native Promise API.

@fredck

This comment has been minimized.

Show comment
Hide comment
@fredck

fredck Feb 20, 2015

+1

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

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

This comment has been minimized.

Show comment
Hide comment
@MrJH

MrJH commented Feb 25, 2015

+1

@masi

This comment has been minimized.

Show comment
Hide comment
@masi

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

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

This comment has been minimized.

Show comment
Hide comment
@mockdeep

mockdeep Jun 19, 2015

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

mockdeep commented Jun 19, 2015

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

@masi

This comment has been minimized.

Show comment
Hide comment
@masi

masi Jun 20, 2015

Shims (polyfills) for promises work well.

masi commented Jun 20, 2015

Shims (polyfills) for promises work well.

@danawoodman

This comment has been minimized.

Show comment
Hide comment
@danawoodman

danawoodman Jul 24, 2015

Any progress on this?

danawoodman commented Jul 24, 2015

Any progress on this?

@kawing-chiu

This comment has been minimized.

Show comment
Hide comment
@kawing-chiu

kawing-chiu Jul 26, 2015

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

kawing-chiu commented Jul 26, 2015

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

Fixed failing tests
* 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

Fixed failing tests
* 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

This comment has been minimized.

Show comment
Hide comment
@dbaba

dbaba Sep 30, 2015

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

dbaba commented Sep 30, 2015

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

@hbrysiewicz

This comment has been minimized.

Show comment
Hide comment

hbrysiewicz commented Dec 15, 2015

+1

@dteleguin

This comment has been minimized.

Show comment
Hide comment
@dteleguin

dteleguin commented Feb 9, 2016

+1

@floverdevel

This comment has been minimized.

Show comment
Hide comment
@floverdevel

floverdevel Feb 10, 2016

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 :)

floverdevel commented Feb 10, 2016

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

This comment has been minimized.

Show comment
Hide comment
@jimmywarting

jimmywarting Feb 10, 2016

@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

jimmywarting commented Feb 10, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@floverdevel

floverdevel Feb 10, 2016

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

floverdevel commented Feb 10, 2016

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

@sickDevelopers

This comment has been minimized.

Show comment
Hide comment

sickDevelopers commented Feb 12, 2016

+1

@msn0

This comment has been minimized.

Show comment
Hide comment
@msn0

msn0 commented Feb 27, 2016

+1

@rafaelhz

This comment has been minimized.

Show comment
Hide comment
@rafaelhz

rafaelhz commented Mar 7, 2016

+1

@jasmith79

This comment has been minimized.

Show comment
Hide comment
@jasmith79

jasmith79 commented Mar 9, 2016

+1

@Jezternz

This comment has been minimized.

Show comment
Hide comment
@Jezternz

Jezternz commented Mar 10, 2016

+1

@inaccessible

This comment has been minimized.

Show comment
Hide comment

inaccessible commented Mar 23, 2016

+1

@AChris07

This comment has been minimized.

Show comment
Hide comment
@AChris07

AChris07 commented Mar 31, 2016

+1

@sygn

This comment has been minimized.

Show comment
Hide comment
@sygn

sygn commented Apr 1, 2016

+1

@msn0

This comment has been minimized.

Show comment
Hide comment
@msn0

msn0 commented Apr 1, 2016

+1

@Radiergummi

This comment has been minimized.

Show comment
Hide comment
@Radiergummi

Radiergummi commented Apr 5, 2016

+1

@jimmywarting

This comment has been minimized.

Show comment
Hide comment
@jimmywarting

jimmywarting Apr 5, 2016

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

jimmywarting commented Apr 5, 2016

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 the Webkit label Apr 11, 2016

@Vitallium Vitallium added this to the FutureRelease milestone Apr 11, 2016

@Vitallium Vitallium self-assigned this Apr 11, 2016

@nmors

This comment has been minimized.

Show comment
Hide comment
@nmors

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

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

This comment has been minimized.

Show comment
Hide comment
@SourceCode

SourceCode 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!

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

This comment has been minimized.

Show comment
Hide comment
@filipalacerda

filipalacerda Jun 17, 2016

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']

filipalacerda commented Jun 17, 2016

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

This comment has been minimized.

Show comment
Hide comment
@ariya

ariya Aug 25, 2016

Owner

Please track ES6 support in #14506. Thank you!

Owner

ariya commented Aug 25, 2016

Please track ES6 support in #14506. Thank you!

@ariya ariya closed this Aug 25, 2016

@baipgydx729

This comment has been minimized.

Show comment
Hide comment
@baipgydx729

baipgydx729 commented Sep 7, 2016

+1

@NeilJ247

This comment has been minimized.

Show comment
Hide comment
@NeilJ247

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

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

This comment has been minimized.

Show comment
Hide comment
@Zoheb-hassan

Zoheb-hassan Jul 20, 2017

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

Zoheb-hassan commented Jul 20, 2017

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

This comment has been minimized.

Show comment
Hide comment
@Somebi

This comment has been minimized.

Show comment
Hide comment
@Somebi

Somebi Sep 24, 2017

+1 :D Get ES6 support faster ffs.

Somebi commented Sep 24, 2017

+1 :D Get ES6 support faster ffs.

@annelledj

This comment has been minimized.

Show comment
Hide comment
@annelledj

annelledj 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']

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']

SilverTiger0224 added a commit to SilverTiger0224/react-ruby that referenced this issue Nov 14, 2017

Fixed failing tests
* 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

chipbell4 added a commit to pbs/Canvas-Drawing-Tool that referenced this issue Nov 15, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.