New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traceur does not work in phantomjs #908

Closed
jsedlacek opened this Issue Mar 24, 2014 · 22 comments

Comments

Projects
None yet
9 participants
@jsedlacek

jsedlacek commented Mar 24, 2014

This is the error I am getting:

ReferenceError: Can't find variable: System at http://localhost:7357/test-compiled.js, line 1
TypeError: 'undefined' is not a function (evaluating 'ModuleStore.register.bind(ModuleStore)') at http://localhost:7357/node_modules/traceur/bin/traceur-runtime.js, line 758

I did not find any browser support table. Is phantomjs supported? It would be very helpful for headless testing.

See failing test here:
https://github.com/jsedlacek/traceur-phantomjs-test

@arv

This comment has been minimized.

Show comment
Hide comment
@arv

arv Mar 24, 2014

Collaborator

It seems like you are not including bin/traceur-runtime.js

Collaborator

arv commented Mar 24, 2014

It seems like you are not including bin/traceur-runtime.js

@jsedlacek

This comment has been minimized.

Show comment
Hide comment
@jsedlacek

jsedlacek Mar 24, 2014

I am including traceur-runtime, see https://github.com/jsedlacek/traceur-phantomjs-test/blob/master/testem.json

The test passes in Chrome, but not in PhantomJS.

jsedlacek commented Mar 24, 2014

I am including traceur-runtime, see https://github.com/jsedlacek/traceur-phantomjs-test/blob/master/testem.json

The test passes in Chrome, but not in PhantomJS.

@arv

This comment has been minimized.

Show comment
Hide comment
@arv

arv Mar 24, 2014

Collaborator

How is PhantomJS started here (sorry for my ignorance, I'm a PhantomJS noob).

It is possible that we inject System on the wrong object in the PhantomJS environment.

Collaborator

arv commented Mar 24, 2014

How is PhantomJS started here (sorry for my ignorance, I'm a PhantomJS noob).

It is possible that we inject System on the wrong object in the PhantomJS environment.

@jsedlacek

This comment has been minimized.

Show comment
Hide comment
@jsedlacek

jsedlacek Mar 24, 2014

It's started automatically by testem. You can also start it manually with

// start.js
var page = require('webpage').create();
page.open('http://localhost:7357/');
$ phantomjs start.js

jsedlacek commented Mar 24, 2014

It's started automatically by testem. You can also start it manually with

// start.js
var page = require('webpage').create();
page.open('http://localhost:7357/');
$ phantomjs start.js
@arv

This comment has been minimized.

Show comment
Hide comment
@arv

arv Mar 24, 2014

Collaborator

PhantomJS uses an ancient version of WebKit that does not support ES5, the immediate issue is that it does not have Function.prototype.bind but Traceur depends on a lot of ES5 features so I doubt polyfilling Function.prototype.bind will be sufficient.

ariya/phantomjs#10522

Collaborator

arv commented Mar 24, 2014

PhantomJS uses an ancient version of WebKit that does not support ES5, the immediate issue is that it does not have Function.prototype.bind but Traceur depends on a lot of ES5 features so I doubt polyfilling Function.prototype.bind will be sufficient.

ariya/phantomjs#10522

@arv arv closed this Mar 24, 2014

@jsedlacek

This comment has been minimized.

Show comment
Hide comment
@jsedlacek

jsedlacek Mar 24, 2014

Function.bind polyfill indeed is not sufficient.

jsedlacek commented Mar 24, 2014

Function.bind polyfill indeed is not sufficient.

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer May 27, 2014

@jsedlacek have you explored what it would take? Is a polyfill possible such as https://github.com/es-shims/es5-shim ?

justinbmeyer commented May 27, 2014

@jsedlacek have you explored what it would take? Is a polyfill possible such as https://github.com/es-shims/es5-shim ?

@jsedlacek

This comment has been minimized.

Show comment
Hide comment
@jsedlacek

jsedlacek May 27, 2014

@justinbmeyer es-5 shim did not solve my issues. I did not dig into that further.

jsedlacek commented May 27, 2014

@justinbmeyer es-5 shim did not solve my issues. I did not dig into that further.

@alexbeletsky

This comment has been minimized.

Show comment
Hide comment
@alexbeletsky

alexbeletsky May 27, 2014

@jsedlacek I'm facing the same issue.. did you found any solutions?

alexbeletsky commented May 27, 2014

@jsedlacek I'm facing the same issue.. did you found any solutions?

@matthewp

This comment has been minimized.

Show comment
Hide comment
@matthewp

matthewp May 28, 2014

The main issue seems to be the use getter/setter syntax when there is an argument named the same as the property, for example: https://github.com/google/traceur-compiler/blob/master/bin/traceur.js#L21774

Would a PR be accepted that updated these to something like set state($state) ... ? @arv

matthewp commented May 28, 2014

The main issue seems to be the use getter/setter syntax when there is an argument named the same as the property, for example: https://github.com/google/traceur-compiler/blob/master/bin/traceur.js#L21774

Would a PR be accepted that updated these to something like set state($state) ... ? @arv

@arv

This comment has been minimized.

Show comment
Hide comment
@arv

arv May 28, 2014

Collaborator

@matthewp Is that all it takes?

I don't mind renaming the param (as long as you do not use $ or _).

Collaborator

arv commented May 28, 2014

@matthewp Is that all it takes?

I don't mind renaming the param (as long as you do not use $ or _).

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer May 28, 2014

@arv how would you like the params renamed generally? argState stateArg?

justinbmeyer commented May 28, 2014

@arv how would you like the params renamed generally? argState stateArg?

@matthewp

This comment has been minimized.

Show comment
Hide comment
@matthewp

matthewp May 28, 2014

@arv I haven't gone through and tried them all since there are a lot. I think it happens like this too for getters:

var SOME_VAR = "foo";

var obj = {
  get SOME_VAR() {
    return SOME_VAR;
  }
}

matthewp commented May 28, 2014

@arv I haven't gone through and tried them all since there are a lot. I think it happens like this too for getters:

var SOME_VAR = "foo";

var obj = {
  get SOME_VAR() {
    return SOME_VAR;
  }
}
@arv

This comment has been minimized.

Show comment
Hide comment
@arv

arv May 28, 2014

Collaborator

Oh, getters are broken too?

Is using a newer version of PhantomJS (non official) or an alternative like SauceLab an option?

Collaborator

arv commented May 28, 2014

Oh, getters are broken too?

Is using a newer version of PhantomJS (non official) or an alternative like SauceLab an option?

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer May 28, 2014

@arv For us personally it might be, but unfortunately, not for our clients/users generally. We are using traceur via SystemJS. There's so much existing test/SEO infrastructure that uses PhantomJS that suggesting a tool that doesn't support it would harm adoption.

We're happy to do all the work / testing to see Phantom working. Let us know if there's anything we else we can do.

justinbmeyer commented May 28, 2014

@arv For us personally it might be, but unfortunately, not for our clients/users generally. We are using traceur via SystemJS. There's so much existing test/SEO infrastructure that uses PhantomJS that suggesting a tool that doesn't support it would harm adoption.

We're happy to do all the work / testing to see Phantom working. Let us know if there's anything we else we can do.

@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic

domenic May 28, 2014

Member

Supporting PhantomJS at this point is like supporting IE8. It should be a non-goal for Traceur.

Member

domenic commented May 28, 2014

Supporting PhantomJS at this point is like supporting IE8. It should be a non-goal for Traceur.

@arv

This comment has been minimized.

Show comment
Hide comment
@arv

arv May 28, 2014

Collaborator

@domenic Agreed

@justinbmeyer If you create a fork that works for you we can at that point look at what was needed. Maybe it is just a few minor things and supporting PhantomJS might be almost free.

Collaborator

arv commented May 28, 2014

@domenic Agreed

@justinbmeyer If you create a fork that works for you we can at that point look at what was needed. Maybe it is just a few minor things and supporting PhantomJS might be almost free.

@alexbeletsky

This comment has been minimized.

Show comment
Hide comment
@alexbeletsky

alexbeletsky May 28, 2014

@domenic I don't agree.. I wish I can run the tests of transpiled code with phantomjs runner. It's faster than karma or anything else.

alexbeletsky commented May 28, 2014

@domenic I don't agree.. I wish I can run the tests of transpiled code with phantomjs runner. It's faster than karma or anything else.

@matthewp

This comment has been minimized.

Show comment
Hide comment
@matthewp

matthewp May 28, 2014

@arv Yeah it happens in getters as well, for example:

return {get ArrayMap() {
      return ArrayMap;
    }};

But this is generated code, so not as easy to fix.

matthewp commented May 28, 2014

@arv Yeah it happens in getters as well, for example:

return {get ArrayMap() {
      return ArrayMap;
    }};

But this is generated code, so not as easy to fix.

@traviskaufman

This comment has been minimized.

Show comment
Hide comment
@traviskaufman

traviskaufman Sep 4, 2014

+1 for PhantomJS support. We really want to start using traceur at Refinery29 but we use karma + PhantomJS to run our tests on our CI server, and since we're a TDD shop not being able to run our tests on continuous integration is a deal-breaker.

traviskaufman commented Sep 4, 2014

+1 for PhantomJS support. We really want to start using traceur at Refinery29 but we use karma + PhantomJS to run our tests on our CI server, and since we're a TDD shop not being able to run our tests on continuous integration is a deal-breaker.

@jmcriffey

This comment has been minimized.

Show comment
Hide comment
@jmcriffey

jmcriffey Sep 4, 2014

Contributor

ariya/phantomjs#12154

@traviskaufman I ran into this a long time ago, and it is most definitely a getter/setter issue that has to do with the version of QtWebKit that PhantomJS uses. I am not convinced it will be addressed any time soon.

I was able to hack around this by minifying my tests, because it removes the suspect syntax, but that is not ideal when you want get useful information out of coverage reports. If you don't need helpful coverage, I would just minify the tests. Otherwise, I would suggest not using PhantomJS, because you are running you tests against a broken JavaScript engine.

Contributor

jmcriffey commented Sep 4, 2014

ariya/phantomjs#12154

@traviskaufman I ran into this a long time ago, and it is most definitely a getter/setter issue that has to do with the version of QtWebKit that PhantomJS uses. I am not convinced it will be addressed any time soon.

I was able to hack around this by minifying my tests, because it removes the suspect syntax, but that is not ideal when you want get useful information out of coverage reports. If you don't need helpful coverage, I would just minify the tests. Otherwise, I would suggest not using PhantomJS, because you are running you tests against a broken JavaScript engine.

@pflannery

This comment has been minimized.

Show comment
Hide comment
@pflannery

pflannery Sep 4, 2014

Contributor

I had these issues too but it forced me to discover a better way of running my CI tests without PhantomJS. It turns out that using a virtual framebuffer, karma and firefox you can run tests on a linux server box.
This may sound unauthordox but it's what the karma team uses instead of PhantomJS. see their travis script here

Basically the key is to run this before running your karma ci test.

export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start

I use grunt to execute my karma config with firefox as the browser and singleRun set to true so the process closes after the tests are run ;)

Contributor

pflannery commented Sep 4, 2014

I had these issues too but it forced me to discover a better way of running my CI tests without PhantomJS. It turns out that using a virtual framebuffer, karma and firefox you can run tests on a linux server box.
This may sound unauthordox but it's what the karma team uses instead of PhantomJS. see their travis script here

Basically the key is to run this before running your karma ci test.

export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start

I use grunt to execute my karma config with firefox as the browser and singleRun set to true so the process closes after the tests are run ;)

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