Search code examples
javascriptdebuggingnode.jschainingsoda

Inspect a Method Chain with a Degugger in Node.js


I am trying to debug this kind of thing :

browser
  .chain
  .session()
  .open('/')
  .type('q', 'Hello World')
  .click('btnG')
  .waitForTextPresent('Hello World')
  .getTitle(function(title){
    assert.ok(~title.indexOf('hello world'), 'Title did not include the query: ' + title);
  })
  .click('link=Advanced search')
  .waitForPageToLoad(2000)
  .assertText('css=#gen-query', 'Hello World')
  .assertAttribute('as_q@value', 'Hello World')
  .end(function(err){
    browser.testComplete(function(){
      console.log('done');
      if (err) throw err;
    });
  });

I've managed to hook up a debugger using directly node debug app.js or using node-inspector and chrome. But, when I try to create a breakpoint at .click('btnG'), it doesn't work, it only makes a breakpoint at the end of the chain. node.js seems to treat the whole chain as a single statement.

How you debug this kind of chaining step by step? How you can inject a REPL in this? Thank You!


Solution

  • Try the tap method in underscore.js