0

Testing a Rails app with rspec & poltergeist, my tests have suddenly started raising

Facebook Pixel Error: ReferenceError: Can't find variable: Set
           at http://connect.facebook.net/en_US/fbevents.js:24 in fc

There is a FB pixel embedded in the page, but I cannot figure out what is causing this error. I am unable to recreate it in a browser. I have been unable to track down the reference to Set variable in fbevents.js or anywhere else.

Has anyone experienced this, or knows how to resolve?

Andy Harvey
  • 12,333
  • 17
  • 93
  • 185

1 Answers1

1

It's likely because the version of PhantomJS that you're using doesn't support JavaScript ES6.

Josh Brody
  • 5,153
  • 1
  • 14
  • 25
  • thanks @Josh Brody, I feared that the issue might be something like that. I'm running phantomjs v 2.1.1. Am I correct that there is currently no newer version with ES6 support? – Andy Harvey Jun 02 '17 at 04:31
  • from what I gather, there's a beta version of phantomjs v2.5 that has ES6 support. you may want to try your luck with it. source: https://stackoverflow.com/questions/29736114/how-to-use-es6-with-phantomjs — but that's _obviously_ no fun. just implement Set yourself! :) – Josh Brody Jun 02 '17 at 04:35
  • This is the correct reference? https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Set On a separate issue, I still can't see how or where https://connect.facebook.net/en_US/fbevents.js is making use of `Set` – Andy Harvey Jun 02 '17 at 04:48
  • That looks to be what I'd expect for Set(), yeah. I know you've probably done this already, but does removing fbevents.js from the code result in any errors? I am by no means a Javascript expert but, like you, I can't see how they're using Set. – Josh Brody Jun 02 '17 at 04:55
  • removing fbevents.js clears the errors, so I guess it is the culprit. an intriguing mystery where Set is being used however! – Andy Harvey Jun 02 '17 at 05:15