Async tests with NightWatchJS - "TypeError: done is not a function"

804 views
Skip to first unread message

Monish Gupta

unread,
May 10, 2016, 10:48:43 AM5/10/16
to NightwatchJs
I need to write some async tests for which I tried the example given in the NightWatchJs developer guide.


Example of async test from dev. guide:
module.exports = {
  'demo UnitTest' : function (client, done) {
    client.assert.ok('TEST');
    setTimeout(function() {
      done();
    }, 500);
  }
};

Getting TypeError: done is not a function. Full output:

Starting selenium server... started - PID:  3610


[Nightwatch Test] Test Suite

============================


Running:  demo UnitTest

  Passed [ok]: TEST ok


An error occurred while running the tests:

TypeError: done is not a function

    at null._onTimeout (/Users/guptam/Documents/repos/time-dfp/tests/automation/nightwatch-test.js:25:7)

    at Timer.listOnTimeout (timers.js:92:15)



Any pointers on the cause of above error? Thanks in advance. Please let me know if anything unclear.

Andrei Rusu

unread,
May 11, 2016, 7:46:27 AM5/11/16
to nightw...@googlegroups.com
You have to disable the automatic selenium session:
http://nightwatchjs.org/guide#unit-testing
> --
> You received this message because you are subscribed to the Google Groups
> "NightwatchJs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nightwatchjs...@googlegroups.com.
> To post to this group, send email to nightw...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nightwatchjs/0d1b3c39-bb3b-44ba-8b1e-a8103f76dd43%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Monish Gupta

unread,
May 11, 2016, 10:24:22 AM5/11/16
to NightwatchJs
Thanks Andrei for the response.

But then, how do I start the selenium session from within the test? client.url is not defined in the test scope.

Andrei Rusu

unread,
May 12, 2016, 3:41:27 AM5/12/16
to nightw...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages