WebdriverIO offers a tight integration to CI systems like Jenkins. With the
junit reporter, you can easily debug your tests as well as keep track of your test results. The integration is pretty easy.
- Install the
$ npm install @wdio/junit-reporter --save-dev)
- Update your config to save your XUnit results where Jenkins can find them,
(and specify the
It is up to you which framework to choose. The reports will be similar. For this tutorial, we’ll use Jasmine.
After you have written couple of tests, you can setup a new Jenkins job. Give it a name and a description:
Then make sure it grabs always the newest version of your repository:
Now the important part: Create a
build step to execute shell commands. The
build step needs to build your project. Since this demo project only tests an external app, you don't need to build anything. Just install the node dependencies and run the command
npm test (which is an alias for
If you have installed a plugin like AnsiColor, but logs are still not colored, run tests with environment variable
FORCE_COLOR=1 npm test).
After your test, you’ll want Jenkins to track your XUnit report. To do so, you have to add a post-build action called "Publish JUnit test result report".
You could also install an external XUnit plugin to track your reports. The JUnit one comes with the basic Jenkins installation and is sufficient enough for now.
According to the config file, the XUnit reports will be saved in the project’s root directory. These reports are XML files. So, all you need to do in order to track the reports is to point Jenkins to all XML files in your root directory:
That's it! You’ve now set up Jenkins to run your WebdriverIO jobs. Your job will now provide detailed test results with history charts, stacktrace information on failed jobs, and a list of commands with payload that got used in each test.