Test automation is an essential part of delivering high quality software.
What is End to End testing?
End to end testing simulates user flows, it ensures that features work from a users perspective by running the tests. After you are done with coding and ready to demo your application to the customer, you can be confident that everything works as expected.
Let’s dive in…
It can be tricky to set up the environment and configure the browser drivers. Installing and configuring all needed packages and all other requirements to have e2e tests running is a lengthy process especially in different environments.
To overcome that, we use Docker. Docker allows us to easily build and run environments with all we need.
There are plenty of test frameworks these days, but in our case we’ll use
“A Next generation of WebDriver test framework for Node.js”. – WebdriverIO
When it comes to test framework, Selenium is a popular open-source web-based automation tool. It consists of hubs and nodes. Selenium automation works on top of WebDriver protocol which is implemented by W3C and supported by all major browsers. It’s worth mentioning that with WebDriverIO you can take screenshots and videos of your tests.
You’ll need support for running docker and docker-compose commands on your local machine or even development machine to have your infrastructure ready. Running the selenium/hub docker, selenium/node-chrome (or/and Firefox docker), along with your wdio container you’ll be able to execute tests against your application. Be aware that the application you want to run the tests for should be dockerized as well to avoid as mentioned before any lengthy process installation requirements. (docker >=19.03.5 and docker-compose >=1.24.1)

It’s time to write the first test that’ll be located by default in the ./test/specs folder (be aware that it can be changed in wdio.config.js file). Let’s make a simple test to check the title of our Makeen website page.
Create a file makeen.js in specs folder:
const assert = require(‘assert’)
describe(‘makeen.io page’, () => {
it(‘should have the right title’, () => {
browser.url(‘https://makeen.io’)
assert.strictEqual(browser.getTitle(), ‘Turn your Bright Ideas into Powerful Outcomes | Makeen Technologies’)
})
})
Now run your wdio container and you’ll see a test executed against the browsers. As the result you’ll see:

In case you have multiple tests and you want only one to be executed you can run execute the following command:
docker-compose exec wdio npm run spec ./test/specs/makeen.js
You can run as many tests as you want, in our example we have only one to show how you can test the title of your page.
If you want to have a nice looking report of your tests, take a look at Allure report provided by Webdriverio.

You can easily set it by following the instructions from the webdriver.io doc page. When it comes to get the report from the wdio container, in your docker-compose file add it as a parameter in volumes, that’d do a trick for you.
However if you also want an email report, one of the ideas would be the hooks. WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance. onComplete gets executed after all workers have shut down and the process is about to exit and it provides test results. Using nodemailer and promises you can send emails with your test results.
We hope you enjoyed reading this article, If you have any questions or doubts do not hesitate to contact us, we’ll gladly help you!