question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceError: Can't find variable: Promise

See original GitHub issue

I get the error ReferenceError: Can't find variable: Promise when I use selectChoose in an acceptance test. It runs fine in the browser but fails in the console.

I’m using Ember 2.11.1, Ember Power Select 1.8.5 and Phantom JS 2.1.1.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cibernoxcommented, Jun 19, 2017

Ok, I’ve found the cause. It turns out it is a problem with promises and regenerator.

  function _asyncToGenerator(fn) {
    return function () {
      var gen = fn.apply(this, arguments);
      return new Promise(function (resolve, reject) { // <===== here!
        function step(key, arg) {
          try {
            var info = gen[key](arg);
            var value = info.value;
          } catch (error) {
            reject(error);
            return;
          }
         // ... more code
      });
    };
  }

In recent versions of EPS I started using async await on tests to people can do things like await selectChoose('#my-select', 'Barry'). But while I take care of conditionally import the regenerator runtime in browsers that don’t support generators, seems that the runtime relies on the existence of a global promise.

I’ll investigate if there is a workaround. In the meanwhile my advice is:

  • Kill PhantomJS with 🔥 . It is a terrible, bug-ridden browser that literally 0 ppl in the world use.
  • Include the babel polyfill, perhaps conditionally only in testing. This problem doesn’t affect the behaviour of the select in browsers without promises like IE, only affects testing.
1reaction
danielleadamscommented, Jun 14, 2017

That’ll do it! My initial instinct was that it was babel-related, but I must not have configured the polyfill correctly in the build file. Thanks @luketheobscure!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't find variable: Promise in Phantomjs - Stack Overflow
I am writing test cases with Jasmin. When I call bellow method,. initialize({"Data": "primary"});. Which is: initialize: function ...
Read more >
ReferenceError: Can't find variable: RTCRtpReceiver
hi, I try to build a mobile app with react-native , on server side everything works perfectly i can create router and send ......
Read more >
ReferenceError: Can't find variable: process - ServiceNow
The java console reports "ReferenceError: Can't find variable: process". Pushing the component to my dev instance the component works fine.
Read more >
ReferenceError: "x" is not defined - JavaScript - MDN Web Docs
The JavaScript exception "variable is not defined" occurs when there is a non-existent variable referenced somewhere.
Read more >
ReferenceError: Can't find variable - Codecademy
ReferenceError : Can't find variable ... If you get an error like this it is because you are trying to enter a string...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found