Overview
In this tutorial, we will create some E2E tests in JavaScript for Node.js, using TestCafé.
Requirements
- TestCafé
- testcafe-reporter-xunit
Description
The following examples are taken from TestCafé's documentation; the first one implements a test .
Simple message validation after submission of input
Implementing tests using page object pattern
In this scenario, taken from TestCafé's documentation, we start by defining a page object.
Two tests can easily be implemented using the previous page object, one of them iterating over a bunch of checkboxes.
Running the tests
In this example, we'll run the tests using Chrome browser. It is also possible to perform headless testing (e.g. use "chrome:headless" as the browser name, for example).
testcafe chrome test1.js test2.js --reporter xunit > results.xml
After running the tests and generating the JUnit XML reports (e.g., results.xml), they can be imported to Xray (either by the REST API or through the Import Execution Results action within the Test Execution).
JUnit's Test Case is mapped to a Generic Test in Jira, and the Generic Test Definition field contains the value of the "it" concatenated with the several "describe"' that make up the test case.
The Execution Details of the Generic Test contains information about the Test Suite, which in this case corresponds to the concatenation of the test's "describe".
References
- https://devexpress.github.io/testcafe/
- https://devexpress.github.io/testcafe/documentation/getting-started/
- https://devexpress.github.io/testcafe/documentation/recipes/using-page-model.html
- https://github.com/DevExpress/testcafe-reporter-xunit