In cucumber.js, how do you access a debugger while in a step definition?

2,505 views
Skip to first unread message

c22...@gmail.com

unread,
Dec 21, 2013, 7:08:29 PM12/21/13
to cu...@googlegroups.com
Here's the only step definition

````
my_only_feature_wrapper = ->
  @World = require('../support/world.coffee').World
  @Given "I am on the home page", (cb) ->
    @visit "http://localhost:4444/", cb
  @Then "I should see the text 'Hello World'", (title, cb) ->
    debugger
    # pageTitle = @browser.text 'title'
    # if title == pageTitle then cb()
    # else cb.fail  new Error("Expected to be on page with title " + title)

module.exports = my_only_feature_wrapper
````
Here's what happens when I attempt to evaluate the test:

````
$ cucumber.js my_only_feature.feature
.%
$
````
The supporting file is straight from the README:

````
zombie = require "zombie"
World = World = (callback) ->
  @browser = new zombie() # this.browser will be available in step definitions
  @visit = (url, callback) ->
    @browser.visit url, callback

  # tell Cucumber we're finished and to use 'this' as the world instance
  callback()

exports.World = World
````

Has anyone successfully accessed a debugger while using Cucumber.js?

Julien Biezemans

unread,
Dec 27, 2013, 12:01:50 PM12/27/13
to cu...@googlegroups.com
You need to tell Node to activate the VM debugger. To do so you'll have to explicitly invoke Node. I got it working, breakpoints and REPL available in my stepdefs with the following:

    $ node debug node_modules/.bin/cucumber.js -f pretty features/my.feature

HTH,

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Julien.

Founder, Cucumber Ltd.

Totty s

unread,
Jan 19, 2015, 6:43:09 PM1/19/15
to cu...@googlegroups.com
That didn't worked for me. here is my solution: node --debug-brk node_modules/cucumber/bin/cucumber.js  "./tests/server" --format pretty

Julien Biezemans

unread,
Jan 20, 2015, 9:08:47 AM1/20/15
to cu...@googlegroups.com
On Tue Jan 20 2015 at 11:43:57 AM Totty s <webdesi...@gmail.com> wrote:
That didn't worked for me. here is my solution: node --debug-brk node_modules/cucumber/bin/cucumber.js  "./tests/server" --format pretty


That's because you didn't set any breakpoint in your code before running the command. --debug-brk will pause the script on it's very first line.
 
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages