nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.8k stars 1.31k forks source link

Mocha support #234

Closed NickColley closed 10 years ago

NickColley commented 10 years ago

Is there anyway I use Mocha to structure my nightwatch tests? :)

beatfactor commented 10 years ago

not at the moment, sorry.

darthjoel commented 9 years ago

+1 to running nightwatch from mocha

maitriyogin commented 8 years ago

Hi, I'm having trouble getting my mocha / nightwatch tests running ... I keep getting : describe is not defined when the test is picked up ... I'v added the test_runner : "test_runner": {"type": "mocha"} created a nightwatch runner script : #!/usr/bin/env node require('nightwatch/bin/runner.js'); and am running : ./nightwatch It just doesn't look like mocha is getting picked up ... Any ideas? /Stephen.

maitriyogin commented 8 years ago

I managed to get this working by just using

"test_runner":"mocha"

instead of

"test_runner": {"type": "mocha"}

Tokimon commented 8 years ago

I am having the same problem, but I would like to use another reporter but when I add this to the config:

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

This setting is taken from the docs (except for 'nyan'), but it doesn't work. Only with:

"test_runner" : "mocha"
beatfactor commented 8 years ago

You're getting the error because you have "tdd" as the "ui" property. If you set it to bdd it should work. Maybe I should also update the docs.

maitriyogin commented 8 years ago

ahh ok, will try it out. Cheers, Stephen.

On 27 Oct 2015, at 15:54, Andrei Rusu notifications@github.com wrote:

You're getting the error because you have "tdd" as the "ui" property. If you set it to bdd it should work. Maybe I should also update the docs.

— Reply to this email directly or view it on GitHub https://github.com/nightwatchjs/nightwatch/issues/234#issuecomment-151529060.

Tokimon commented 8 years ago

This works perfectly. Thanks! But yes please update the docs then as the example there doesn't work.

LKay commented 8 years ago

I have the same problem. I have no idea what is wrong as everything seems exactly the same as in the docs.

My config looks like:

require("babel-core/register")

module.exports = (() => {

  return {
    "src_folders" : ["test/e2e"],
    "selenium" : {
      "start_process" : false,
      "server_path" : "",
      "log_path" : "",
      "host" : "127.0.0.1",
      "port" : 4444,
      "cli_args" : {
        "webdriver.chrome.driver" : ""
      }
    },

    "test_settings" : {
      "default" : {
        "launch_url" : "http://localhost:8000",
        "test_runner" : {
          "type" : "mocha",
          "options" : {
            "ui" : "bdd",
            "reporter" : "spec"
          }
        }
      }
    }
  }
})()

Yet I can't run my tests receiving ReferenceError: describe is not defined all the time. I'm using sample test from docs:

describe('Google demo test for Mocha', function() {

    describe('with Nightwatch', function() {

        before(function(client, done) {
            done();
        });

        after(function(client, done) {
            client.end(function() {
                done();
            });
        });

        afterEach(function(client, done) {
            done();
        });

        beforeEach(function(client, done) {
            done();
        });

        it('uses BDD to run the Google simple test', function(client) {
            client
                .url('http://google.com')
                .expect.element('body').to.be.present.before(1000);

            client.setValue('input[type=text]', ['nightwatch', client.Keys.ENTER])
                .pause(1000)
                .assert.containsText('#main', 'Night Watch');
        });
    });
});
lovedota commented 8 years ago

@LKay

I got a same problems with you and then i tried

"test_settings": {
    "default": {
      "launch_url": "",
      "selenium_port": 4444,
      "selenium_host": "localhost",
      "silent": true,
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    }
  },
"test_runner" : "mocha"

and it works well.

Huffman17 commented 5 years ago

I have tried all suggestions in this ticket and still not having any luck trying to use mocha, describe is not defined when running nightwatch path/to/test within cli