['1', '2', '3']
, your Cypress autotests have these IDs in results = ['1', '2', '3', '4']
=> error! because Test Rail doesn't contain Test Case with ID = 4
.
- Clone this project:
https://github.com/Smoliarick/cypress-testrail-integration-example.git
for HTTPS[email protected]:Smoliarick/cypress-testrail-integration-example.git
for SSH
- Run
npm install
command - Create
.env
file with configs for Test Rail. You can use this example:
TESTRAIL_USERNAME=your_testrail_username
TESTRAIL_PASSWORD=your_testrail_password
TESTRAIL_HOSTNAME=https://your_domain.testrail.io/
TESTRAIL_PROJECT_ID=your_testrail_project_id
- Create several Test Cases into your Test Rail and add their IDs into the autotests using this template:
it('C1, C2: Verify that google page has input field', () => {
cy.visit('https://www.google.com/');
cy.get('input').should('be.visible');
});
where C1
and C2
are Test Case IDs. You can use another letter for Test Case IDs. Add ,
to separate several Test Case IDs. If you want to use only 1 Test Case ID, don't add a new ,
. Example:
it('C3: Verify that google page doesn\'t have input field ', () => {
cy.visit('https://www.google.com/');
cy.get('input').should('not.be.visible');
});
- Run
npx cypress run
command - When Cypress Run is completed, open Test Runs in Test Rail. New Test Run with default name (e.g.
2023-01-03 Test Run: Cypress Autotest
) and results from Cypress Run should be created
Default template for autotests:
it('[Test Case IDs with any first letter]: [Autotest\'s title]', () => {
// autotest
});
Example:
it('C1, C2: Verify that google page has input field', () => {
// autotest
});
it('C3: Verify that google page doesn\'t have input field ', () => {
// autotest
});
If you want to add a new parser for autotest's titles, add it into the constructor. Example:
setupNodeEvents(on, config) {
on('after:run', async (results) => {
function newParser(title) { // new parser
const splittedTitle = title.split(':');
const testCaseIds = splittedTitle[0]
.split(',')
.map((element) => element = element.trim().substring(1));
return testCaseIds;
}
const TestrailIntegration = require('cypress-testrail-integration');
const testrailIntegration = new TestrailIntegration(
process.env.TESTRAIL_USERNAME,
process.env.TESTRAIL_PASSWORD,
process.env.TESTRAIL_HOSTNAME,
process.env.TESTRAIL_PROJECT_ID,
parser = newParser // adding a new parser
);
await testrailIntegration.addResultsToTestRailTestRun(results);
});
return config;
},
['1', '2', '3', '4', '5', '6', '7']
or ['1']
for 1 Test Case ID.
Default name is [Today's date] Test Run: Cypress Autotest
, e.g. 2023-01-03 Test Run: Cypress Autotest
.
If you want to add a new name for Test Rail Test Run, add it into the constructor. Example:
setupNodeEvents(on, config) {
on('after:run', async (results) => {
const TestrailIntegration = require('cypress-testrail-integration');
const testrailIntegration = new TestrailIntegration(
process.env.TESTRAIL_USERNAME,
process.env.TESTRAIL_PASSWORD,
process.env.TESTRAIL_HOSTNAME,
process.env.TESTRAIL_PROJECT_ID,
testRunName = 'New Test Run' // adding a new name for Test Run
);
await testrailIntegration.addResultsToTestRailTestRun(results);
});
return config;
},