nightwatch-cucumber icon indicating copy to clipboard operation
nightwatch-cucumber copied to clipboard

How to run individual feature in nightwatch js ?

Open veenadamo opened this issue 7 years ago • 3 comments

I am new to nightwatch js , currently I an trying to test multiple use cases using nightwatch js, I have followed standard directory structure.

I have usecase1.feature and usecase2.feature files in my features folder and usecase1.js and usecase2.js files in my step_definitions folder.

my package.json file is shown below:

{ "scripts" : { "usecase1" : "nightwatch", "usecase2" : nightwatch" } }

If I tried to run only usecase1 using command : 'npm run usecase1' but this is executing both usecase1 and usecase2 , My Intention is to run each individual use case separately. Can someone please help me with this.

veenadamo avatar Aug 07 '18 03:08 veenadamo

You can run a single feature file with nightwatch usecase1.feature

mucsi96 avatar Aug 12 '18 06:08 mucsi96

Thanks Igor , But this fails if there is, say a step which is common in both of my features for ex: both usecase1.feature and usecase2.feature have a step "validate order id" , in this case when I run only usecase1.feature the scenario fails with error : 'Multiple step definitions match'. In this case I have to make sure nothing is common in both my use cases , is there a way I can overcome this ?

veenadamo avatar Aug 19 '18 01:08 veenadamo

@veenadamo cucumber always scans your step-definition directory. so there should be only step-definition. if your feature file has same step there should be only one implementation 1.either make the step definition unique for usecase1 and usecase2 feature 2.remove and keep only one step definition

satheesh6789 avatar Dec 23 '19 13:12 satheesh6789