0

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!

cyrfandli
  • 249
  • 1
  • 3
  • 12

3 Answers3

3

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.

JSantaCL
  • 500
  • 4
  • 12
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!

Silicium
  • 435
  • 8
  • 18
  • Your solution worked for me simply installing the latest phantomjs without having to modify and directories. – Errol Mar 28 '16 at 16:51
  • This solution also worked for me. I am using Windows 10, Node 4.4.5, DalekJS CLI 0.0.5, DalekJS 0.0.9, PhantomJS 2.1.1 – Grasshopper Jul 13 '16 at 15:55
1

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!

Selly
  • 331
  • 3
  • 3
  • npm install dalekjs --save-dev is failing...i.e. installation is paused on phantomjs installing time. Any idea ? I am using OS X – N Kaushik Oct 28 '15 at 13:31
  • Hey @Selly how did you solve step 4? The Github issues don't look like they're actually solved. I can't install `dalek` without `sudo` ... – dooburt Nov 26 '15 at 10:00
  • Whit Sillicum said :) – Selly May 20 '16 at 00:35