问题
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:
- Do DalekJS installation as suggested
npm install phantom phantomjs -g
- Check phantomJS installation running
phantomjs -v
- (optional) run dalek again to see it fail
- Search for local phantomjs installations running
find . -name 'phantom*'
and identify dalek's phantomjs dependency - Delete dalek's phantomjs dependency running
rm -fr ./node_modules/dalek-browser-phantomjs/node_modules/phantomjs
- 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
- 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:
- Download the latest phantom.js from npm (npm install phantomjs)
- 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:
- Install the pacakges:
sudo npm install dalek-cli -g
- Configure your directory with the default "package.json" file --it sounds like you've already done 1 & 2
- Then open a CLI/terminal and go to the directory with your package.json and your "tests" directory.
- 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