How do I run only Test 3
from the following tests?
module.exports = { 'Test 1':function(){}, 'Test 2':function(){} 'Test 3':function(){} }
A new parameter --testcase has been added to run a specified testcase. Show activity on this post. Test 2 and Test 3 will be executed. Separate each test function is mandatory because Nightwatch handled with filematcher each file.
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.
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.
A new parameter --testcase has been added to run a specified testcase.
nightwatch.js --test tests\demo.js --testcase "Test 1"
It's a new feature since the v0.6.0
https://github.com/beatfactor/nightwatch/releases/tag/v0.6.0
You must use specific tags before function and separate all functions in diferent files under tests directory, and then call command with --tag argument. See wiki nightwatch tags page and watch this example:
// --- file1.js --- module.exports = { tags: ['login'], 'Test 1':function(){ //TODO test 1 } }; // --- file2.js --- module.exports = { tags: ['special', 'createUser'], 'Test 2':function(){ //TODO test 2 }, }; // --- file3.js --- module.exports = { tags: ['logoff', 'special'], 'Test 3':function(){ //TODO test 3 }, }
If you run:
nightwatch.js --tag login
only runs Test 1, however if you run:
nightwatch.js --tag special
Test 2 and Test 3 will be executed.
You can specific more than one tag
nightwatch.js --tag tag1 --tag tag2
Separate each test function is mandatory because Nightwatch handled with filematcher each file. See Github code.
PD: If file has syntax errors, is possible that test don't run or test hasn't been found
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With