Transcripted Summary

In this lecture, we are going to be discussing grouping tests by suites.

Grouping your tests by suites makes it easier for you to run a suite of tests versus running everything, even though you may not need to run all the tests. It also makes it easier for you to run a specific set of tests instead of specifying the path to the test.


The first thing that we need to do is to go into our “package.json” and in our scripts we are going to add a suite.

Let us call this suite “actions: and we are going to say


"scripts": {
    "test": "node ./node_modules/.bin/wdio ./wdio.conf.js",
    "actions": "./node_modules/.bin/wdio ./wdio.conf.js --suite actions"
}

In our test folder, let us create a subfolder called “actions”.

And we are going to move our elementActions.test.js to that folder.



Okay, so our elementActions.test.js is now in the subfolder called “actions”.


We are then going to go into our “wdio.conf.js” file and we are going to add our suites.

We can add this anywhere in our file.

Let us say suite:{ then the name of our suite, which is “actions”.

Then we're going to put the path for this action suite, which is “./test/actions/” — then we are going to use an Asterisk which is a catch all to say “within actions any file that ends with a ‘js’ we are going to run it”.


suites: {
    actions: [
        './test/actions/*.js'
    ]
}



We can use two commands to run our suite:


npm run --suite actions

Or to run elementActions.test.js:


npm run actions

So, let us run that second option



And it runs our elementActions.test suite.

So, this is very useful if it is that you want to a group of tests.

It saves you the time of just calling npm run test as that will run everything, even those you don't want running at that time.



Resources



Quiz

The quiz for this chapter can be found in section 6.5

© 2024 Applitools. All rights reserved. Terms and Conditions Privacy Policy GDPR