-1

We are using Grunt to kick off NightWatch.js tests. There are like 30-40 tests and this number will grow a lot more.

For now, I am aware of only two reasonable ways to choose which tests get run and they are both manual:
1. Remove all tests that shouldn't be run from source folder
2. Comment/UnComment the '@disabled': true, annotation

I was thinking that a properly structured way of choosing which tests get run would be to have a certain file, say, "testPlan.txt" like this:
test1 run test2 not test3 run
And then the test could have some code, instead of the current annotation, such as this (sorry, my JS is non-existent):

if (checkTestEnabled()) then ('@disabled': true) else (//'@disabled': true)
DraxDomax
  • 1,008
  • 1
  • 9
  • 28
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. See the [ask] page for help clarifying this question. – Patrick Hund Jan 02 '18 at 12:18
  • @PatrickHund, I think the question is exactly the correct breadth. I've shown my work that demonstrates I am not aware of any way to centralise test execution toggling (I am 90% sure there's no built-in way of doing that in NW.js). As a matter of fact, I feel that if I were to choose a specific method of doing that, it would make the question too narrowly applicable. – DraxDomax Jan 02 '18 at 14:14

1 Answers1

1

You can use tags to group your tests into categories and then pick and choose which tests to run based on the flag you pass in. For example, if I wanted to create a smoke test suite I would just add '@tags': ['smokeTests'] at the top of each file that would be included in that suite and then you can run them using the command:

nightwatch --tag smokeTests

You can also add multiple tags to each test if you need to group them in additional categories. '@tags': ['smokeTests', 'login']

You should be able to use this the same way you are doing it in your grunt tasks. Read here for more details.

DraxDomax
  • 1,008
  • 1
  • 9
  • 28
tehbeardedone
  • 2,833
  • 1
  • 15
  • 23
  • I think that should solve my problem adequately. I just want to ask about the link you provided. It says: "You can also selectively target tests to run based on tags, such that a test may be belong to multiple tags." Does that mean I can add multiple tag lines in one file? like:@tags: ['smokeTests'] ...line break... @tags: ['integrationTests']. If you could elaborate on this in your answer, I think it will be complete and ready for acceptance. – DraxDomax Jan 05 '18 at 15:36
  • Updated my answer with an example of how to do multiple tags. Just think of the tags as an array of strings. You can add as many as you need all on the same line. No need for multiple lines. – tehbeardedone Jan 05 '18 at 16:11
  • I am going to edit your answer, as it's a bit discombobulated from previous edit. I'll accept it then but I hope I didn't misconstrue anything of what you've said :) – DraxDomax Jan 05 '18 at 18:08