qansigliere-testrail-api-integration
v1.1.2
Published
The main idea of this library created in the JavaScript language is to provide a ready-made set of API methods for integration with Testrail
Downloads
40
Maintainers
Readme
qansigliere-testrail-api-integration
The main idea of this library created in the JavaScript language is to provide a ready-made set of API methods for integration with Testrail
Author
https://www.youtube.com/@QANSIGLIERE/
Installation
Using npm npm i qansigliere-testrail-api-integration
How to use it
Create a *.env file
Create any *.env file (like testrail.env
) and write the following information in the created file
export TESTRAIL_URL="__YOUR_TESTRAIL_URL__"
export TESTRAIL_USERNAME="__YOUR_TESTRAIL_EMAIL__"
export TESTRAIL_APIKEY="__YOUR_TESTRAIL_APIKEY__"
Make the *.env file works
Just run in the terminal the following command: source yourfile.env
And now You can make any API call to Your TestRail
var { TestRail_API } = require('qansigliere-testrail-api-integration');
(async function Demo() {
let new_integration = new TestRail_API();
let resp = await new_integration.get_templates(1);
console.log(JSON.stringify(resp));
})();
API Documentation
Case Types
TestRail documentation is present here
get_case_types
let new_integration = new TestRail_API();
let resp = await new_integration.get_case_types();
Roles
TestRail documentation is present here
get_roles
let new_integration = new TestRail_API();
let resp = await new_integration.get_roles();
Statuses
TestRail documentation is present here
get_case_statuses
let new_integration = new TestRail_API();
let resp = await new_integration.get_case_statuses();
get_statuses
let new_integration = new TestRail_API();
let resp = await new_integration.get_statuses();
Templates
TestRail documentation is present here
get_templates
let new_integration = new TestRail_API();
let resp = await new_integration.get_templates(1);
Priorities
TestRail documentation is present here
get_priorities
let new_integration = new TestRail_API();
let resp = await new_integration.get_priorities();
Result Fields
TestRail documentation is present here
get_result_fields
let new_integration = new TestRail_API();
let resp = await new_integration.get_result_fields();
Runs
TestRail documentation is present here
get_run
let new_integration = new TestRail_API();
let resp = await new_integration.get_run(1);
get_runs
let new_integration = new TestRail_API();
let resp = await new_integration.get_runs(1);
add_run
let new_integration = new TestRail_API();
let resp = await new_integration.add_run(1, {
suite_id: 3,
name: 'Generated by QANSIGLIERE',
description: 'Created for DEMO',
include_all: true,
});
update_run
let new_integration = new TestRail_API();
let resp = await new_integration.update_run(2, {
description: 'A description for the test run',
include_all: true,
});
close_run
let new_integration = new TestRail_API();
let resp = await new_integration.close_run(2, {});
delete_run
let new_integration = new TestRail_API();
let resp = await new_integration.delete_run(2, {});
BDDs
TestRail documentation is present here
get_bdd
let new_integration = new TestRail_API();
let resp = await new_integration.get_bdd(5);
add_bdd
let new_integration = new TestRail_API();
let resp = await new_integration.add_bdd(1, `test.txt`);
Case Fields
TestRail documentation is present here
get_case_fields
let new_integration = new TestRail_API();
let resp = await new_integration.get_case_fields();
add_case_field
let new_integration = new TestRail_API();
let resp = await new_integration.add_case_field({
"type": "Multiselect",
"name": "my_multiselect",
"label": "My Multiselect",
"description": "my custom Multiselect description",
"configs": [
{
"context": {
"is_global": true,
"project_ids": ""
},
"options": {
"is_required": false,
"items": "1, One\n2, Two"
}
}
],
"include_all": true
});
Reports
TestRail documentation is present here
get_reports
let new_integration = new TestRail_API();
let resp = await new_integration.get_reports(1);
run_report
let new_integration = new TestRail_API();
let resp = await new_integration.run_report(1);
Variables
TestRail documentation is present here
get_variables
let new_integration = new TestRail_API();
let resp = await new_integration.get_variables(1);
add_variable
let new_integration = new TestRail_API();
let resp = await new_integration.add_variable(1, { id: 613, name: 'f' });
update_variable
let new_integration = new TestRail_API();
let resp = await new_integration.update_variable(1, {
id: 1171,
name: 'age',
});
delete_variable
let new_integration = new TestRail_API();
let resp = await new_integration.delete_variable(1, {});
Projects
TestRail documentation is present here
get_project
let new_integration = new TestRail_API();
let resp = await new_integration.get_project(1);
get_projects
let new_integration = new TestRail_API();
let resp = await new_integration.get_projects();
add_project
let new_integration = new TestRail_API();
let resp = await new_integration.add_project({
name: 'Generated via QANSIGLIERE API library',
announcement: 'Welcome to my project',
show_announcement: true,
});
update_project
let new_integration = new TestRail_API();
let resp = await new_integration.update_project(7, {
name: 'Updated via QANSIGLIERE API library',
announcement: 'Subscribe to the channel',
show_announcement: true,
});
delete_project
let new_integration = new TestRail_API();
let resp = await new_integration.delete_project(7, {});
Results
TestRail documentation is present here
get_results
let new_integration = new TestRail_API();
let resp = await new_integration.get_results(14));
get_results_for_case
let new_integration = new TestRail_API();
let resp = await new_integration.get_results_for_case(4, 14);
get_results_for_run
let new_integration = new TestRail_API();
let resp = await new_integration.get_results_for_run(4);
add_result
let new_integration = new TestRail_API();
let resp = await new_integration.add_result(14, { status_id: 5, comment: 'This test failed' });
add_result_for_case
let new_integration = new TestRail_API();
let resp = await new_integration.add_result_for_case(4, 16, { status_id: 1, comment: 'This test passed' });
add_results
let new_integration = new TestRail_API();
let resp = await new_integration.add_results(4, {
results: [
{
test_id: 17,
status_id: 1,
comment: 'This test failed',
defects: 'TR-7',
},
{
test_id: 18,
status_id: 5,
comment: 'This test passed',
elapsed: '5m',
version: '1.0 RC1',
},
{
test_id: 19,
status_id: 2,
comment: 'Assigned this test to Joe',
},
],
});
add_results_for_cases
let new_integration = new TestRail_API();
let resp = await new_integration.add_results_for_cases(4, {
results: [
{
case_id: 17,
status_id: 1,
comment: 'This test failed',
defects: 'TR-7',
},
{
case_id: 18,
status_id: 5,
comment: 'This test passed',
elapsed: '5m',
version: '1.0 RC1',
},
{
case_id: 19,
status_id: 2,
comment: 'Assigned this test to Joe',
},
],
});
Suites
TestRail documentation is present here
get_suite
let new_integration = new TestRail_API();
let resp = await new_integration.get_suite(10);
get_suites
let new_integration = new TestRail_API();
let resp = await new_integration.get_suites(4);
add_suite
let new_integration = new TestRail_API();
let resp = await new_integration.add_suite(4, {
name: 'This is a new test suite',
description: 'Use the description to add additional context details',
});
update_suite
let new_integration = new TestRail_API();
let resp = await new_integration.update_suite(11, {
name: 'This is changed via API',
description: 'Like this video',
});
delete_suite
let new_integration = new TestRail_API();
let resp = await new_integration.delete_suite(11, {});
Sections
TestRail documentation is present here
get_section
let new_integration = new TestRail_API();
let resp = await new_integration.get_section(9);
get_sections
let new_integration = new TestRail_API();
let resp = await new_integration.get_sections(8, 10);
add_section
let new_integration = new TestRail_API();
let resp = await new_integration.add_section(8, {
suite_id: 10,
name: 'This section is generated via API',
parent_id: 9,
});
move_section
let new_integration = new TestRail_API();
let resp = await new_integration.move_section(10, {
parent_id: null,
after_id: 8,
});
update_section
let new_integration = new TestRail_API();
let resp = await new_integration.update_section(10, {
name: 'Updated via API',
});
delete_section
let new_integration = new TestRail_API();
let resp = await new_integration.delete_section(10, {});
Milestones
TestRail documentation is present here
get_milestone
let new_integration = new TestRail_API();
let resp = await new_integration.get_milestone(1);
get_milestones
let new_integration = new TestRail_API();
let resp = await new_integration.get_milestones(4);
add_milestone
let new_integration = new TestRail_API();
let resp = await new_integration.add_milestone(4, {
name: 'This milestone has been created via API',
});
update_milestone
let new_integration = new TestRail_API();
let resp = await new_integration.update_milestone(2, {
name: 'Updated via API',
});
delete_milestone
let new_integration = new TestRail_API();
let resp = await new_integration.delete_milestone(2, {});
Groups
TestRail documentation is present here
get_group
let new_integration = new TestRail_API();
let resp = await new_integration.get_group(1);
get_groups
let new_integration = new TestRail_API();
let resp = await new_integration.get_groups();
add_group
let new_integration = new TestRail_API();
let resp = await new_integration.add_group({
name: 'New Group',
user_ids: [1, 2, 3, 4, 5],
});
update_group
let new_integration = new TestRail_API();
let resp = await new_integration.update_group(2, {
group_id: 2,
name: 'Updated Group via API',
user_ids: [1, 2, 3, 4, 5],
});
delete_group
let new_integration = new TestRail_API();
let resp = await new_integration.delete_group(2, {});
Users
TestRail documentation is present here
get_user
let new_integration = new TestRail_API();
let resp = await new_integration.get_user(1);
get_current_user
let new_integration = new TestRail_API();
let resp = await new_integration.get_current_user(1);
get_user_by_email
let new_integration = new TestRail_API();
let resp = await new_integration.get_user_by_email('[email protected]');
get_users
let new_integration = new TestRail_API();
let resp = await new_integration.get_users();
get_users__project_id
let new_integration = new TestRail_API();
let resp = await new_integration.get_users__project_id(1);
add_user
let new_integration = new TestRail_API();
let resp = await new_integration.add_user({
name: 'Don Gun',
email: '[email protected]',
});
update_user
let new_integration = new TestRail_API();
let resp = await new_integration.update_user(2, {
name: 'Updated API',
});
Tests
TestRail documentation is present here
get_test
let new_integration = new TestRail_API();
let resp = await new_integration.get_test(20);
get_tests
let new_integration = new TestRail_API();
let resp = await new_integration.get_tests(5);
// let resp = await new_integration.get_tests('5&limit=30&status_id=2');
Shared Steps
TestRail documentation is present here
get_shared_step
let new_integration = new TestRail_API();
let resp = await new_integration.get_shared_step(1);
get_shared_step_history
let new_integration = new TestRail_API();
let resp = await new_integration.get_shared_step_history(1);
get_shared_steps
let new_integration = new TestRail_API();
let resp = await new_integration.get_shared_steps(4);
add_shared_step
let new_integration = new TestRail_API();
let resp = await new_integration.add_shared_step(4, {
title: 'First Step',
custom_steps_separated: [
{
content: 'Open home page',
additional_info: 'Must be a new browser session',
expected: 'Login page loads',
refs: 'RF-1',
},
{
content: 'Log In',
},
],
});
update_shared_step
let new_integration = new TestRail_API();
let resp = await new_integration.update_shared_step(2, {
title: 'Updated VIA API',
custom_steps_separated: [
{
content: 'Subscribe',
additional_info: 'Must be a new comment here',
expected: 'Login page loads',
refs: 'RF-1',
},
{
content: 'Log In',
},
],
});
delete_shared_step
let new_integration = new TestRail_API();
let resp = await new_integration.delete_shared_step(2, {});
Datasets
TestRail documentation is present here
get_dataset
let new_integration = new TestRail_API();
let resp = await new_integration.get_dataset(1);
get_datasets
let new_integration = new TestRail_API();
let resp = await new_integration.get_datasets(4);
add_dataset
let new_integration = new TestRail_API();
let resp = await new_integration.add_dataset(4, {
id: 311,
name: 'Def',
variables: [],
});
update_dataset
let new_integration = new TestRail_API();
let resp = await new_integration.update_dataset(3, {
name: 'API',
variables: [],
});
delete_dataset
let new_integration = new TestRail_API();
let resp = await new_integration.delete_dataset(3, {});
Cases
TestRail documentation is present here
get_case
let new_integration = new TestRail_API();
let resp = await new_integration.get_case(14);
get_cases
let new_integration = new TestRail_API();
let resp = await new_integration.get_cases(4, 6);
// let resp = await new_integration.get_cases(4, '6&priority_id=4');
get_history_for_case
let new_integration = new TestRail_API();
let resp = await new_integration.get_history_for_case(14);
add_case
let new_integration = new TestRail_API();
let resp = await new_integration.add_case(5, {
title: 'This is a test case',
type_id: 1,
priority_id: 3,
estimate: '3m',
refs: 'RF-1, RF-2',
custom_steps_separated: [
{
content: 'Step 1',
expected: 'Expected Result 1',
},
{
content: 'Step 2',
expected: 'Expected Result 2',
},
{
shared_step_id: 3,
},
],
});
copy_cases_to_section
let new_integration = new TestRail_API();
let resp = await new_integration.copy_cases_to_section(5, {
section_id: 5,
case_ids: [22, 23]
});
update_case
let new_integration = new TestRail_API();
let resp = await new_integration.update_case(11, {
priority_id: 1,
estimate: "5m"
});
update_cases
let new_integration = new TestRail_API();
let resp = await new_integration.update_cases(6, {
case_ids: [26, 27],
priority_id: 1,
estimate: "5m"
});
move_cases_to_section
let new_integration = new TestRail_API();
let resp = await new_integration.move_cases_to_section(12, {
section_id: 12,
suite_id: 6,
case_ids: [26, 27]
});
delete_case
let new_integration = new TestRail_API();
let resp = await new_integration.delete_case(25, {});
delete_cases
let new_integration = new TestRail_API();
let resp = await new_integration.delete_cases(6, {
case_ids: [23, 24],
});
Plans
TestRail documentation is present here
get_plan
let new_integration = new TestRail_API();
let resp = await new_integration.get_plan(6);
get_plans
let new_integration = new TestRail_API();
let resp = await new_integration.get_plans(9);
add_plan
let new_integration = new TestRail_API();
let resp = await new_integration.add_plan(9, {
name: "System test",
entries: [
{
suite_id: 12,
name: "Custom run name",
assignedto_id: 1 // ID of the assignee
},
{
suite_id: 12,
include_all: false, // Custom selection
case_ids: [28, 29, 30]
}
]
});
add_plan_entry
let new_integration = new TestRail_API();
let resp = await new_integration.add_plan_entry(9, {
suite_id: 12,
include_all: true,
runs: [
{
"include_all": false,
"case_ids": [28],
},
{
"include_all": false,
"case_ids": [28, 29, 30],
},
]
});
add_run_to_plan_entry
let new_integration = new TestRail_API();
let resp = await new_integration.add_run_to_plan_entry(9, "0e165a00-bf50-4482-bde1-3134c1dacd50", {
config_ids: [1],
include_all: false,
case_ids: [28, 29, 30]
});
update_plan
let new_integration = new TestRail_API();
let resp = await new_integration.update_plan(9, {
name: "Updated VIA API",
});
update_plan_entry
let new_integration = new TestRail_API();
let resp = await new_integration.update_plan_entry(9, "0e165a00-bf50-4482-bde1-3134c1dacd50", {
name: "updated too",
description: "it was updated via qansigliere JS lib"
});
update_run_in_plan_entry
let new_integration = new TestRail_API();
let resp = await new_integration.update_run_in_plan_entry(10, {
include_all: true,
});
close_plan
let new_integration = new TestRail_API();
let resp = await new_integration.close_plan(14, {});
delete_plan
let new_integration = new TestRail_API();
let resp = await new_integration.delete_plan(15, {});
delete_plan_entry
let new_integration = new TestRail_API();
let resp = await new_integration.delete_plan_entry(9, "0e165a00-bf50-4482-bde1-3134c1dacd50", {});
delete_run_from_plan_entry
let new_integration = new TestRail_API();
let resp = await new_integration.delete_run_from_plan_entry(21, {});
Configurations
TestRail documentation is present here
get_configs
let new_integration = new TestRail_API();
let resp = await new_integration.get_configs(9);
add_config_group
let new_integration = new TestRail_API();
let resp = await new_integration.add_config_group(9, {
name: "Browsers"
});
add_config
let new_integration = new TestRail_API();
let resp = await new_integration.add_config(3, {
name: "Chrome"
});
update_config_group
let new_integration = new TestRail_API();
let resp = await new_integration.update_config_group(3, {
"name": "Operating Systems"
});
update_config
let new_integration = new TestRail_API();
let resp = await new_integration.update_config(3, {
"name": "Firefly"
});
delete_config_group
let new_integration = new TestRail_API();
let resp = await new_integration.delete_config_group(3, {});
delete_config
let new_integration = new TestRail_API();
let resp = await new_integration.delete_config(3, {});
Attachments
TestRail documentation is present here
add_attachment_to_case
let new_integration = new TestRail_API();
let resp = await new_integration.add_attachment_to_case(24, 'icon.png');
add_attachment_to_plan
let new_integration = new TestRail_API();
let resp = await new_integration.add_attachment_to_plan(16, 'icon.png');
add_attachment_to_plan_entry
let new_integration = new TestRail_API();
let resp = await new_integration.add_attachment_to_plan_entry(16, "0e165a00-bf50-4482-bde1-3134c1dacd50", 'icon.png');
add_attachment_to_result
let new_integration = new TestRail_API();
let resp = await new_integration.add_attachment_to_result(46, 'icon.png');
add_attachment_to_run
let new_integration = new TestRail_API();
let resp = await new_integration.add_attachment_to_run(22, 'icon.png');
get_attachments_for_case
let new_integration = new TestRail_API();
let resp = await new_integration.get_attachments_for_case(28);
// let resp = await new_integration.get_attachments_for_case('11&limit=1');
get_attachments_for_plan
let new_integration = new TestRail_API();
let resp = await new_integration.get_attachments_for_plan(16);
get_attachments_for_plan_entry
let new_integration = new TestRail_API();
let resp = await new_integration.get_attachments_for_plan_entry(16, "0e165a00-bf50-4482-bde1-3134c1dacd50");
get_attachments_for_run
let new_integration = new TestRail_API();
let resp = await new_integration.get_attachments_for_run(10);
get_attachments_for_test
let new_integration = new TestRail_API();
let resp = await new_integration.get_attachments_for_test(26);
get_attachment
let new_integration = new TestRail_API();
let resp = await new_integration.get_attachment('30a47475-de26-4215-9459-b9094aa3b42e');
delete_attachment
let new_integration = new TestRail_API();
let resp = await new_integration.delete_attachment('30a47475-de26-4215-9459-b9094aa3b42e', {});
Related Videos
- https://youtube.com/live/q2NO23ruDqI?feature=share
- https://youtube.com/live/IC4hoYwzvDY?feature=share
- https://youtube.com/live/o9yonQpeFg4?feature=share
- https://youtube.com/live/qjw5o0Kk6iQ?feature=share
- https://youtube.com/live/XRJWPa8UW3M?feature=share
- https://youtube.com/live/4y6EgblRqP0?feature=share
- https://youtube.com/live/fTWMR7L6sCE?feature=share
- https://youtube.com/live/XG9moLSdXuk?feature=share
- https://youtube.com/live/bUy-FJYVz2M?feature=share