The following code and the setup instructions were inspired on CodeceptJS startup tutorial.
Our Feature contains 3 Scenarios, where the last one was intended to fail on purpose.
After running the tests and generating the JUnit XML report (e.g., output/result.xml), it can be imported to Xray (either by the REST API or through the Import Execution Results action within the Test Execution).
Each Scenario is mapped to a Generic Test in Jira, and the Generic Test Definition field contains the name of the Scenario concatenated with the name of the Feature.
The Execution Details of the Generic Test contains information about the Test Suite, which in this case corresponds to the name of the Feature.