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.79k stars 1.31k forks source link

Error: done is not a function #2448

Closed LukasGaebler closed 4 years ago

LukasGaebler commented 4 years ago

Describe the bug

Im trying to run nightwatch tests in a vue application. When calling done() in the globals.js file I'm getting an arror which says "TypeError: done is not a function.

module.exports = {
    before: (done) => {
        console.log("Tests have started");
        done();
    }
}

This is my configuration:

module.exports = {
  src_folders: ["tests/e2e"],
  test_settings: {
    default: {
      launch_url: 'https://nightwatchjs.org'
    }
  },
  webdriver: {
    start_process: true,
    port: 4444,
    server_path: require('geckodriver').path
  }
};

and I'm calling the tests with this command:

vue-cli-service test:e2e --use-selenium

Sample test

This is the test I'm trying to run

module.exports = {
    'test' (browser) {
      browser
        .url('http://news.ycombinator.com')
        .waitForElementVisible('.hnname', 1000)
        .assert.containsText(".hnname", "Hacker News")
    }
  };
LukasGaebler commented 4 years ago

Update: I added the browser property to the before function:

before: (browser, done) => {
        console.log("Tests have started");
        done();
    }

Now I get the error, that cb is not a function. It seems, that I forgot a callback or something like that.... but I can't find the place where it should be

LukasGaebler commented 4 years ago

Update: I found the solution in this (https://github.com/nightwatchjs/nightwatch/issues/1629) issue. I had the wrong directory structure.