Standard mocha code in the documentation doesn't work

603 views
Skip to first unread message

Prakash Karaka

unread,
Dec 19, 2015, 12:50:28 AM12/19/15
to NightwatchJs
Hello I am trying to make the below code. the standard mocha code sample  in the documentation here http://nightwatchjs.org/guide


I am seeing below error:
 1) Github "before all" hook:
     Uncaught TypeError: object is not a function
      at Nightwatch.<anonymous> (node_modules/nightwatch/lib/runner/clientmanager.js:43:9)
      at Nightwatch.finished (node_modules/nightwatch/lib/index.js:243:8)
      at node_modules/nightwatch/lib/index.js:207:10
      at AsyncTree.<anonymous> (node_modules/nightwatch/lib/core/queue.js:212:9)

Please help me in fixing it. No clue how to proceed further


var nightwatch = require('nightwatch');

describe('Github', function() {
  var client = nightwatch.initClient({
    silent : true
  });

  var browser = client.api();

  this.timeout(99999999);

  before(function() {

    browser.perform(function() {
      console.log('beforeAll')
    });

  });

  beforeEach(function(done) {
    browser.perform(function() {
      console.log('beforeEach')
    });

    client.start(done);
  });


  it('Demo test GitHub', function (done) {
    browser
      .waitForElementVisible('body', 5000)
      .assert.title('nightwatchjs/nightwatch · GitHub')
      .waitForElementVisible('body', 1000)
      .assert.visible('.container .breadcrumb a span')
      .assert.containsText('.container .breadcrumb a span', 'nightwatch', 'Checking project title is set to nightwatch');

    client.start(done);
  });

  afterEach(function() {
    browser.perform(function() {
      console.log('afterEach')
    });
  });

  after(function(done) {
    browser.end(function() {
      console.log('afterAll')
    });

    client.start(done);
  });

});

Prakash Karaka

unread,
Dec 20, 2015, 3:25:52 AM12/20/15
to NightwatchJs
Could someone help me here.

Mallikarjun Javali

unread,
Dec 22, 2015, 1:19:11 AM12/22/15
to NightwatchJs
Hi ,
I am also facing the same issue.

I have modified nightwatch.json to add

"test_runner" : {
  "type" : "mocha",
  "options" : {
    "ui" : "bdd",
    "reporter" : "nyan"
  }

Then I run ./bin/nightwatch -t ./examples/mocha/googleDemoTest.js
I am getting following error

ReferenceError: describe is not defined
    at Object.<anonymous> (/home/mallik/nightwatch/examples/mocha/googleDemoTest.js:1:63)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at new Module (/home/mallik/nightwatch/lib/runner/module.js:7:23)
    at new TestSuite (/home/mallik/nightwatch/lib/runner/testsuite.js:17:17)
    at runTestModule (/home/mallik/nightwatch/lib/runner/run.js:38:19)

Thanks,
Mallik

PrzemuH

unread,
Jul 6, 2016, 10:01:44 AM7/6/16
to NightwatchJs
Hey,

Check out my repo with simple Google example:

https://github.com/przemuh/nightwatch-mocha

Petar S

unread,
Jan 19, 2017, 8:03:18 AM1/19/17
to NightwatchJs
Is there any solution for this ?
Reply all
Reply to author
Forward
0 new messages