I want to set an id to each test in Jest so that I can uniquely identify them.
It is something similar to @TestParamters
/ @Parameters
in TestNG.
Here - https://www.gurock.com/testrail/docs/api/reference/results#addresult . If you look the end-point given here, it ask for :test_id
.
So, I also want to give an id to each of my test cases and fetch that id in TestRail.
Check @jest-reporters/testrail plugin. It is a TestRail module for Jest. Helps to create test runs on TestRail for multiple suites and send results.
First, install the plugin
npm i @jest-reporters/testrail
Second, update jest.config.js
module.exports = {... reporters: [ ["testrail", { project_id: "1" }] ] };
Third, in your test case files
// "1:" this is Suite ID from Test Rail (Will work only for top) describe("TestRail[1] Suite", () => { // "11:" this is Case ID from Test Rail it("TestRail[11] Test success", async() => { expect(1).toBe(1); }); it("TestRail[12] Test fail", async() => { expect(1).toBe(0); }); xit("TestRail[13] Test skip", async() => { expect(1).toBe(1); }); });
The Suite ID from TestRail must be added to the start of top describe() description, ID should be in TestRail[ID].
The Case ID from TestRail must be added to the start of each it() description, ID should be in TestRail[ID].
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.