
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
cypress-testrail-integration
Advanced tools
This package helps to create a new Test Run in Test Rail with results from Cypress Run.
⚠️ Check that all Test Case IDs, which you use, are existed in Test Rail. If you try to add a new Test Run (if you don't use existed Test Run ID), it doesn't work, because Test Rail API doesn't allow creating a new Test Run using non-existed IDs. Example: you have these Test Case IDs = ['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
.
cypress.config.js
filenpm i cypress-testrail-integration
cypress.config.js
file.env
file):TESTRAIL_USERNAME=your_testrail_username
TESTRAIL_PASSWORD=your_testrail_password
TESTRAIL_HOSTNAME=https://your_domain.testrail.io/
TESTRAIL_PROJECT_ID=your_testrail_project_id
after-run-api
part of the cypress config file (use credentials and data for Test Rail from step 1).addResultsToTestRailTestRun
method for creating a new Test Run in Test Rail (with Test Case IDs from autotests) and adding results into created Test Run.Full code:
const { defineConfig } = require('cypress');
require('dotenv').config();
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('after:run', async (results) => {
// Export package
const TestrailIntegration = require('cypress-testrail-integration');
// Create a new object with Test Rail credentials and data
const testrailIntegration = new TestrailIntegration(
process.env.TESTRAIL_USERNAME, // Test Rail username
process.env.TESTRAIL_PASSWORD, // Test Rail password
process.env.TESTRAIL_HOSTNAME, // Test Rail hostname
process.env.TESTRAIL_PROJECT_ID, // Test Rail project_id
);
// Create a new Test Run in Test Rail and add results from Cypress Run
await testrailIntegration.addResultsToTestRailTestRun(results);
});
return config;
},
specPattern: 'cypress/e2e/**/*.spec.{js, jsx, ts, tsx}',
},
});
Update titles for your autotests using this template:
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 completed to updated autotests titles and config file, run this command for test:
npx cypress run
If all works OK, you will see a new Test Run with results. It contains all Test Cases with Test Case IDs from your autotests.
Video example:
If you want to use your own parser and titles for autotests, you can add a new parser into the constructor for TestrailIntegration
.
cypress.config.js
fileTestrailIntegration
constructor as a parser
paramExample:
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;
},
⚠️ Be careful, new parser should return array of the Test Case IDs. Example: ['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;
},
If you want to use created Test Run in Test Rail for adding results, you can add it's ID into the addResultsToTestRailTestRun
method. 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
);
// 25 is ID for existed Test Rail Test Run
await testrailIntegration.addResultsToTestRailTestRun(results, runId = 25);
});
return config;
},
You can use this example: https://github.com/Smoliarick/cypress-testrail-integration-example. This project was set up using cypress-testrail-integration package.
FAQs
TestRail integration for Cypress autotests
The npm package cypress-testrail-integration receives a total of 3 weekly downloads. As such, cypress-testrail-integration popularity was classified as not popular.
We found that cypress-testrail-integration demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.