gruntjs / grunt-contrib-jasmine

Run jasmine specs headlessly through Headless Chrome
http://gruntjs.com/
MIT License
355 stars 197 forks source link

PhantomJS+Grunt+Jasmine = SyntaxError: Parse error #65

Closed PhillyWebGuy closed 10 years ago

PhillyWebGuy commented 11 years ago

I have:

node v0.8.9 npm 1.1.61 grunt-cli v0.1.6 grunt v0.4.1 phantomjs 1.9.0 Mac OS 10.8.1

I execute the following from a terminal:

node_modules/grunt-cli/bin/grunt -v -d 1

And I (partially) get:

Testing jasmine specs via phantom

[D] ["/Users/xxxxx/htdocs/eConnect/poc/com.xxxxxxx.poc/knockout/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/phantomjs/main.js","/var/folders/zp/tj_1pvw52ylc8mc8fsqv65tw0000gn/T/1370273246790.809","_SpecRunner.html","{\"version\":\"1.3.1\",\"timeout\":10000,\"styles\":[],\"specs\":[],\"helpers\":[],\"vendor\":[],\"outfile\":\"_SpecRunner.html\",\"host\":\"\",\"template\":\"/Users/xxxxxx/htdocs/xxxxxx/poc/com.xxxxx.poc/knockout/node_modules/grunt-contrib-jasmine/tasks/jasmine/templates/DefaultRunner.tmpl\",\"templateOptions\":{},\"phantomjs\":{},\"junit\":{}}"]
[D] ["phantomjs","private","version",{"major":1,"minor":9,"patch":0}]
[D] ["phantomjs","onResourceRequested","file:///Users/xxxxx/htdocs/xxxxx/poc/com.xxxxx.poc/knockout/_SpecRunner.html"]
[D] ["phantomjs","onUrlChanged","file:///Users/xxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/_SpecRunner.html"]
[D] ["phantomjs","onResourceRequested","file:///Users/xxxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/.grunt/grunt-contrib-jasmine/jasmine.css"]
[D] ["phantomjs","onResourceRequested","file:///Users/xxxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/.grunt/grunt-contrib-jasmine/jasmine.js"]
[D] ["phantomjs","onResourceRequested","file:///Users/xxxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/.grunt/grunt-contrib-jasmine/jasmine-html.js"]
[D] ["phantomjs","onResourceRequested","file:///Users/xxxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/tests/phonenumbers/phoneModelTest.html"]
[D] ["phantomjs","onResourceRequested","file:///Users/xxxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/.grunt/grunt-contrib-jasmine/reporter.js"]
[D] ["phantomjs","onResourceRequested","file:///Users/xxxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/.grunt/grunt-contrib-jasmine/jasmine-helper.js"]
[D] ["phantomjs","onResourceReceived","file:///Users/xxxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/_SpecRunner.html"]
[D] ["phantomjs","onResourceReceived","file:///Users/xxxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/.grunt/grunt-contrib-jasmine/jasmine.css"]
[D] ["phantomjs","onResourceReceived","file:///Users/xxxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/.grunt/grunt-contrib-jasmine/jasmine.js"]
[D] ["phantomjs","onInitialized"]
[D] ["phantomjs","onResourceReceived","file:///Users/xxxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/.grunt/grunt-contrib-jasmine/jasmine-html.js"]
[D] ["phantomjs","onResourceReceived","file:///Users/xxxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/tests/phonenumbers/phoneModelTest.html"]
[D] ["phantomjs","error.onError","SyntaxError: Parse error",[]]
>> SyntaxError: Parse error
[D] ["phantomjs","onResourceReceived","file:///Users/xxxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/.grunt/grunt-contrib-jasmine/reporter.js"]
[D] ["phantomjs","onResourceReceived","file:///Users/xxxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/.grunt/grunt-contrib-jasmine/jasmine-helper.js"]
[D] ["phantomjs","jasmine.reportRunnerStarting",[]]
Starting...
[D] ["phantomjs","jasmine.reportRunnerResults",{}]
Runner finished
0 specs in 0s.
[D] ["phantomjs","jasmine.reportJUnitResults",{"suites":[],"consolidatedSuites":{}}]
[D] ["phantomjs","jasmine.done.PhantomReporter"]
>> 0 failures

In particular, I am interested in:

 ["phantomjs","error.onError","SyntaxError: Parse error",[]]
>> SyntaxError: Parse error

And, also the fact that it should be running at least 1 spec, but appears not to be when it reports 0 specs in 0s.

I also ran against the sample SpecRunner.html and I get the same results.

jsoverson commented 11 years ago

Unfortunately, phantomjs does not give us details of the syntax error (see https://github.com/gruntjs/grunt-contrib-jasmine/issues/37).

You could use a task just before jasmine that validates your javascript using a task like grunt-jsvalidate

PhillyWebGuy commented 11 years ago

Yeah, I've tried grunt-jsvalidate and jshint and I'm not getting any hints.

PhillyWebGuy commented 11 years ago

I just downgraded to PhantomJS 1.3.0 and Jasmine 1.2.0 and still the same problem.

jsoverson commented 11 years ago

Have you tried opening the _SpecRunner.html file that remains after a failed run in a browser?

This line is a concern

[D] ["phantomjs","onResourceReceived","file:///Users/xxxxxx/htdocs/eConnect/poc/com.xxxxxx.poc/knockout/tests/phonenumbers/phoneModelTest.html"]

It seems like you might be loading an html file as the src. Grunt-contrib-jasmine is meant to automatically generate your specrunner from source js files. You can use templates to automatically generate one specific to your needs, if necessary.

jsoverson commented 11 years ago

@PhillyWebGuy ping for update

tjwebb commented 10 years ago

Same problem here.

jsoverson commented 10 years ago

@tjwebb can you open another ticket with details regarding your issue? This issue looks like it was related to comment https://github.com/gruntjs/grunt-contrib-jasmine/issues/65#issuecomment-18868103 and without updates from @PhillyWebGuy I don't want to hijack it for another problem.