What is this DalekJS error when I try to run a test via PhantomJS?

和自甴很熟 提交于 2020-01-06 07:26:13

问题


Every time I try to run a test using PhantomJS, Dalek gives me this error. However using GoogleChrome the test runs properly.

Running tests

/Users/user/node_modules/dalekjs/node_modules/dalek-browser-phantomjs/index.js:273

this.spawned.kill('SIGTERM');

            ^



TypeError: Cannot read property 'kill' of null

  at Object.PhantomJSDriver.kill (/Users/user/node_modules/dalekjs/node_modules/dalek-browser-phantomjs/index.js:273:17)

  at EventEmitter.emit (/Users/user/node_modules/dalekjs/node_modules/eventemitter2/lib/eventemitter2.js:312:17)

  at Object.Dalek._shutdown (/Users/user/node_modules/dalekjs/lib/dalek.js:346:24)

  at emitOne (events.js:77:13)

  at process.emit (events.js:169:7)

  at process._fatalException (node.js:211:26)

What could the problem be?

Please note that I am using OS X 10.10.5 and I am beginner at Dalek and JS test automation. Thanks!


回答1:


Just ran into this issue and after reading a while got to this steps:

  1. Do DalekJS installation as suggested
  2. npm install phantom phantomjs -g
  3. Check phantomJS installation running phantomjs -v
  4. (optional) run dalek again to see it fail
  5. Search for local phantomjs installations running
    find . -name 'phantom*' and identify dalek's phantomjs dependency
  6. Delete dalek's phantomjs dependency running
    rm -fr ./node_modules/dalek-browser-phantomjs/node_modules/phantomjs
  7. Copy the recently installed phantomJS to the just deleted path running
    cp -r /usr/local/lib/node_modules/phantomjs ./node_modules/dalek-browser-phantomjs/node_modules/phantomjs
  8. Run dalek again and your tests should work.

Hope it helps. Best regards.




回答2:


It looks like there are some files missing in dalek-browser-phantomjs

The missing folders/files are from dalek-browser-phantomjs/node-modules/phantomjs/lib

If you install phantomjs (npm install phantomjs) alone you get a file called "location.js" + a directory called "phantom". The location.js file contains the path to phantomjs and the phantom folder holds the binary.

Those two are missing, which leads to the error that this.spawned is set to null which throws the error at dalekjs/node_modules/dalek-browser-phantomjs/index.js:273:17.

So in short:

  1. Download the latest phantom.js from npm (npm install phantomjs)
  2. Replace it with the phantomjs folder in your project. Location:

yourproject/node_modules/dalekjs/node_modules/dalek-browser-phantomjs/node-modules/

Now all your tests should work!




回答3:


I was running into the same problem.

I believe that the issue may be that your "node_modules" directory is being created with root permissions.

So, on the DalekJS home page it simply says to run the npm install commands without sudo or root. The first command installs the modules, the second command, however configures your directory for phantomJS usage--and if you call the second command (npm install dalekjs --save-dev) with root privileges then that will cause problems.

So:

  1. Install the pacakges: sudo npm install dalek-cli -g
  2. Configure your directory with the default "package.json" file --it sounds like you've already done 1 & 2
  3. Then open a CLI/terminal and go to the directory with your package.json and your "tests" directory.
  4. Execute the next npm command WITHOUT ROOT/SUDO privileges: `npm install dalekjs --save-dev' (had to do similar on Ubuntu). Problem I run into next, however is that the npm caommand hangs-- documented here on Github

This worked for me on OS X, and I wasn't able to find a fix anywhere else so thought I'd post... Hope it helps!



来源:https://stackoverflow.com/questions/32714340/what-is-this-dalekjs-error-when-i-try-to-run-a-test-via-phantomjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!