Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to CasperJS for use with Cucumber.js

After lots of research and trial and error I have chosen the following stack for Frontend BDD testing:

  • Cucumber.js
  • CasperJS (through SpookyJS)
  • PhantomJS

I would like to avoid CasperJS run queues and use PhantomJS directly (through phantom-proxy) with callbacks in each step:

@World = (cb) ->
    @phantom = require "phantom-proxy"
    cb()

@Before (cb) ->
    self = this
    @phantom.create {}, (proxy) ->
        self.proxy = proxy
        self.page = proxy.page
        cb()

@After (cb) ->
    @proxy.end ->
        cb()

@When /^I go to url "([^"]*)"$/, (url, cb) ->
    @page.open url, ->
        cb()

making the whole more logical and BDD-like.

Additionally, SpookyJS doesn't provide a full API for CasperJS.

The PhantomJS API, however, is quite low-level. Is there any other tool that provides CasperJS-like functionality (clicking, waiting for elements, etc) for Node.js without using run queues?

like image 389
Ernests Karlsons Avatar asked Mar 08 '13 15:03

Ernests Karlsons


2 Answers

Mocha-PhantomJS might be just what you're looking for.

Alternatively, WebdriverJS has support for cucumber tests.

If you want to be more low-level you can try interfacing with the selenium-webdriver directly. Here's a demo on github.

Good luck!

like image 118
Kites Avatar answered Nov 15 '22 01:11

Kites


I'd recommend Mocha which has a cucumber syntax add-on (mocha-cackes) and/or chai and it's plugins chai-jquery and chai-timers.

Also Karma comes with cucumber syntax support through the plugin karma-cucumber.

Both Karma and Mocha allow you to run your tests against real devices using launchers for saucelabs or browserstack for example.

Hope it helps.

like image 27
svassr Avatar answered Nov 15 '22 02:11

svassr