lucassus / angular-coffee-seed

AngularJS seed based on grunt JavaScript tasks runner and bower a package manager for the web
http://lucassus-angular-seed.herokuapp.com/
MIT License
33 stars 9 forks source link

Problems with PhantomJS for integration tests #82

Closed tylercollier closed 10 years ago

tylercollier commented 10 years ago

First of all, this project is fantastic. It's incredibly clean so is helping me understand how to do things properly. Thanks!

I can't figure out how to run PhantomJS for integration tests. I think the README is missing some steps, or unclear.

I have PhantomJS installed (you might want to mention to run sudo npm install -g phantomjs in the "Install * globally" section). I am running it successfully as instructed:

$ phantomjs --webdriver=4444
PhantomJS is launching GhostDriver...
Ghost Driver running on port 4444

But I'm not sure what exactly needs to be done when you write "run specs". Before that , you wrote "setup protractor browserName: 'phantomjs'", which I did, but that's in a coffeescript file. Somewhere that needs to be turned into JS. So I looked at the README's "How to develop specs" section, which says "run it with grunt coffee:test && protractor dev/test/protractor-conf.js". There is no such coffee task:

$ grunt coffee:test
Running "coffee:test" (coffee) task
Verifying property coffee.test exists in config...ERROR
>> Unable to process task.
Warning: Required config property "coffee.test" missing. Use --force to continue.

Aborted due to warnings.

If I look in build/config/coffee.coffee, there's only a dist task, no test.

If I try to run protractor, the file dev/test/protractor-conf.js doesn't exist. I'm thinking the build:dev grunt task needs to be run, but it doesn't create the dev/test folder. So for the sake of checking, I just compiled that file right there in that directory and ran:

$ protractor test/protractor-conf.js 
Using ChromeDriver directly...

which opens up Chrome, not PhantomJS. So then I figure I need to specify the selenium port and stuff so I uncomment protractor-conf.coffee/js where it has seleniumServerJar and seleniumPort, and run again. Again it launches Chrome, so this time I take out the chromeDriver: null and chromeOnly: true sections. It says unable to start selenium. So I comment seleniumServerJar and seleniumPort back out and add seleniumAddress: "http://localhost:4444".

Finally, it seems to actually be using PhantomJS, but here's what I get:

$ protractor test/protractor-conf.js 
Using the selenium server at http://localhost:4444

  1) Other page "before each" hook
  2) Products page "before each" hook
  3) Tasks page "before each" hook

  0 passing (138ms)
  3 failing

  1) Other page "before each" hook:
     UnknownCommandError: Variable Resource Not Found - Request => {"headers":{"Accept":"application/json; charset=utf-8","Connection":"keep-alive","Content-Length":"21","Content-Type":"application/json;charset=UTF-8","Host":"localhost:4444"},"httpVersion":"1.1","method":"POST","post":"{\"url\":\"about:blank\"}","url":"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/url","urlParsed":{"anchor":"","query":"","file":"url","directory":"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/","path":"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/url","relative":"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/url","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/url","queryKey":{},"chunks":["session","c19a7e90-86bf-11e3-be03-e5fdd5fc5f90","url"]}}
      at new bot.Error (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:109:18)
      at Object.bot.response.checkResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/response.js:103:11)
      at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:276:20
      at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1178:15
      at webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1445:20)
      at notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:328:12)
      at notifyAll (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:297:7)
      at fulfill (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:402:7)
      at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1312:10
      at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1178:15
  ==== async task ====
  WebDriver.navigate().to(about:blank)
      at webdriver.WebDriver.schedule (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:267:15)
      at webdriver.WebDriver.Navigation.to (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:896:23)
      at webdriver.WebDriver.get (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:618:26)
      at Protractor.get (/usr/local/lib/node_modules/protractor/lib/protractor.js:651:15)
      at [redacted]/test/integration/other_scenario.coffee:17:15
      at webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1445:20)
      at webdriver.promise.ControlFlow.runEventLoop_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1310:8)
      at wrapper [as _onTimeout] (timers.js:252:14)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
  ==== async task ====
      at Context.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/testing/index.js:119:12)
      at Hook.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:204:15)
      at next (/usr/local/lib/node_modules/mocha/lib/runner.js:259:10)
      at Object._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:276:5)
      at processImmediate [as _immediateCallback] (timers.js:330:15)

# and two more errors here, basically the same as the first

What's going on? What is that telling me? Am I close to properly using PhantomJS for headless testing?

Also, can you explain the build:dev process to get protractor-conf.js into dev/test?

tylercollier commented 10 years ago

I went back to my window that was running phantomJS, which now had this appended:

Asynchronous Sessions cleanup phase starting NOW
About to delete Session 'c19a7e90-86bf-11e3-be03-e5fdd5fc5f90', because windowless...
... deleted!
Error => {
  "message": "Request => {\"headers\":{\"Accept\":\"application/json; charset=utf-8\",\"Connection\":\"keep-alive\",\"Content-Length\":\"21\",\"Content-Type\":\"application/json;charset=UTF-8\",\"Host\":\"localhost:4444\"},\"httpVersion\":\"1.1\",\"method\":\"POST\",\"post\":\"{\\\"url\\\":\\\"about:blank\\\"}\",\"url\":\"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/url\",\"urlParsed\":{\"anchor\":\"\",\"query\":\"\",\"file\":\"url\",\"directory\":\"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/\",\"path\":\"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/url\",\"relative\":\"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/url\",\"port\":\"\",\"host\":\"\",\"password\":\"\",\"user\":\"\",\"userInfo\":\"\",\"authority\":\"\",\"protocol\":\"\",\"source\":\"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/url\",\"queryKey\":{},\"chunks\":[\"session\",\"c19a7e90-86bf-11e3-be03-e5fdd5fc5f90\",\"url\"]}}",
  "name": "Variable Resource Not Found",
  "line": 81,
  "sourceId": 140159546135808,
  "sourceURL": ":/ghostdriver/request_handlers/router_request_handler.js",
  "stack": "Variable Resource Not Found: Request => {\"headers\":{\"Accept\":\"application/json; charset=utf-8\",\"Connection\":\"keep-alive\",\"Content-Length\":\"21\",\"Content-Type\":\"application/json;charset=UTF-8\",\"Host\":\"localhost:4444\"},\"httpVersion\":\"1.1\",\"method\":\"POST\",\"post\":\"{\\\"url\\\":\\\"about:blank\\\"}\",\"url\":\"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/url\",\"urlParsed\":{\"anchor\":\"\",\"query\":\"\",\"file\":\"url\",\"directory\":\"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/\",\"path\":\"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/url\",\"relative\":\"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/url\",\"port\":\"\",\"host\":\"\",\"password\":\"\",\"user\":\"\",\"userInfo\":\"\",\"authority\":\"\",\"protocol\":\"\",\"source\":\"/session/c19a7e90-86bf-11e3-be03-e5fdd5fc5f90/url\",\"queryKey\":{},\"chunks\":[\"session\",\"c19a7e90-86bf-11e3-be03-e5fdd5fc5f90\",\"url\"]}}\n    at :/ghostdriver/request_handlers/router_request_handler.js:81",
  "stackArray": [
    {
      "sourceURL": ":/ghostdriver/request_handlers/router_request_handler.js",
      "line": 81
    }
  ]
}

I don't understand this either, but maybe the problem is with ghostdriver, rather than with the angular-seed app?

lucassus commented 10 years ago

@tylercollier good catch! I updated notes about running integration specs on PhantomJS browser. Thanks! ;)

lucassus commented 10 years ago

Also, can you explain the build:dev process to get protractor-conf.js into dev/test?

In the previous version I had to compile protractor spec from coffee to js. Currently protractor can directly run specs written in coffeescripts but I forgot to update the docs.