Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you test the results of 'client.execute' in Nighwatch?

Here's the api for client.execute. I'm able to get a value back, but how am I able to actually test that the value is correct? I don't see a generic assert method anywhere.

http://nightwatchjs.org/api/execute.html

like image 982
Aakil Fernandes Avatar asked May 03 '15 17:05

Aakil Fernandes


People also ask

How do you run the Nightwatch test?

Running A Demo TestStep 1: Go to the folder “node_modules/nightwatch/examples/tests/”. Step 2: Under the 'tests' folder, you can find some sample tests. Step 3: Let us run the first sample test “ecosia. js”.

What is Nightwatch testing?

Nightwatch. js is an open-source automated testing framework that is powered by Node. js and provides complete E2E (end to end) solutions to automation testing with Selenium Javascript be it for web apps, browser apps, and websites.

How do you run multiple test cases on Nightwatch?

To execute tests in multiple browsers, you need to add the desired capabilities of the browsers and Test_worker configurations in nightwatch. json file. For example if you want to execute tests in three browsers parallely - Chrome, Firefox and Opera, your nightwatch. json should something like this.

How do you skip the test on Nightwatch?

By simply converting the test method to a string, Nightwatch will ignore it.


1 Answers

Nightwatch.js extends Node.js assert module, so you can also use any of the available methods there in your tests.

'some suite': function (client) {

  client.execute(
    function(greet){
      return greet + " there!";
    },
    "Hello",
    function(result){
      client.assert.equal(result, "Hello there!");
    }
  );

}
like image 114
Jehong Ahn Avatar answered Sep 27 '22 20:09

Jehong Ahn