rundef / node-testrail-api Goto Github PK
View Code? Open in Web Editor NEWAPI wrapper for TestRail
API wrapper for TestRail
If we are using the function below to get all the projects, we have to pass 'is_completed: false' to FILTERS. But I could not retrieve any project with it.
testrail.getProjects(/FILTERS=/{is_completed: false}, function (err, response, projects) {
console.log(projects);
});
While if we look at TestRail API v2 reference, is_completed is either 0 or 1, not true or false. Can you please check?
http://docs.gurock.com/testrail-api2/reference-projects
GET index.php?/api/v2/get_projects&is_completed=0
When trying to make a basic call, I will get a preflight error
Failed to load https://myinstance.testrail.com/index.php?/api/v2/get_project/1: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 400. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Is there a way to set that? Or is there some other special setting I need to do?
Pretty much as the title says, if you use this package in a typescript project, you get errors saying that there are no type definition for the request library. Easy workaround is to install @types/request on the project, but it would be better if the dependency was specified by node-testrail-api
testrail api v2 getSections call requires project_id and suite_id,
call from here only supplied project_id and suite_id is missing.
Thanks for the thorough work; the other available packages were missing various API calls.
We're new to Test Rail and I'm attempting to integrate this into our test automation suite, but every test I run returns undefined. For example:
'use strict';
var Testrail = require('testrail-api');
describe( "This Test Rail test", function ()
{
var testrail = new Testrail({
host: 'https://url.to.host.goes.here',
user: '[email protected],
password: 'API Key goes here'
});
it( "should update the status of Case #2 for Run #2 to Failed", function (done)
{
testrail.addResultsForCases(/*RUN_ID=*/2, /*CONTENT=*/{ "case_id": 2, "status_id": 5, "comment": "this test has failed" }, function (err, results)
{
console.log(results);
done();
});
})
});
Your example for this particular API call didn't specify that an explicit array was required, which is what the API expects, but I've tried it both ways and it returns undefined each time. Apologies if I'm just missing something simple; I am new to Node as well.
Thanks!
Since version 5.7 it is now possible to add attachments via the API.
http://docs.gurock.com/testrail-api2/reference-attachments
Can you put that in?
Greetings Daniel
#8 added a wrapper object to responses returned in the callback and in the promise, but the type definitions were not updated to reflect this change.
Example
testrail.getRun(1).then(run => {
console.log(run.id) // Type definitions say `id` exists, but logs `undefined`
console.log(run.body.id) // Type error, but logs `1`
})
The following code block works with a runId printing:
before(function () {
testrail.getRuns(/*PROJECT_ID=*/1, /*FILTERS=*/{}, function (err, response, runs) {
let runId = runs[0].id
console.log('runId:', runId)
});
})
This code does not work with no print occurring at all. There is no error either as err is null.
after(function () {
testrail.getRuns(/*PROJECT_ID=*/1, /*FILTERS=*/{}, function (err, response, runs) {
let runId = runs[0].id
console.log('runId:', runId)
});
})
I've used this before without the issue, but now this is happening in a new implementation. What could be causing this?
Hello there again.
Do you mind if we add some more response to each api call?
As it is right now, we can't deal different status codes as the package just doesn't sends them through with the response's body.
I'll do a Pull Request for it, if you don't mind. We can discuss further then.
There is a error in the code: index.js line 90: callback(err.message || err)
but this code branch executed when typeof callback !== 'function'
{ error: 'Undefined property: stdClass::$dataset_id' }
After all requests.
Can someone help?
The newest release for Testrail will update JSON response object to all Bulk API endpoints.
Right now before the update is released, it is possible to receive the new JSON response object by including the ‘x-api-ident’: ‘beta’
header/value pair in API requests.
Is there support for being able to query the beta bulk API endpoints and also node-testrail-api support for the new offset and limit parameters for the new pagination features?
What sort of things would need to be improved in order to achieve this testrail functionality on this npm package?
Can someone merge the new PRs that passed all checks?
Actually into the TestRails Api we can use a token instead of username/password, so I've a token for that and in this repo I can't found any way to use it. Please add support for this kind of tokens. Thanks.
I get this error when I try to test testrail.deleteSection
Here's the output message in my terminal.
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Request._callback (...path/node_modules/testrail-api/index.js:88:29)
at Request.self.callback (...path/node_modules/request/request.js:186:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.<anonymous> (...path/node_modules/request/request.js:1163:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (...path/node_modules/request/request.js:1085:12)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1055:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
And here's my test code:
const sectionObject = {
name: 'Test Section',
};
testrailInstance.addSection(projectId, sectionObject)
.then((result) => {
testrailInstance.deleteSection(result.id)
.then(console.log)
.catch(console.log);
})
.catch(console.error);
What's going on here? It can't JSON.parse
the result?
Since recent TestRail update, they introduced pagination, e.g. https://www.gurock.com/testrail/docs/api/reference/tests#gettests
We need to use offset
(Number that sets the position where the response should start from (Optional parameter) (requires TestRail 6.7 or later)), but the current methods do not support offset configuration:
testrail.getTests(/*RUN_ID=*/1, /*FILTERS=*/{}, function (err, response, tests) {
console.log(tests);
});
Are you planning to add it?
According to the API for results, elapsed
is a string and not a number: http://docs.gurock.com/testrail-api2/reference-results#apiresults
Hi,
if i submit this request with valid data:
testrail.addResults(300, {"results": [{"test_id": 301386, "status_id": 5, "comment": "This test failed", "defects": "TR-7"}]})
than i get following error message:
{"message":{"error":"Field :results.test_id is a required field."},"response":{"statusCode":400,"body":"{"error":"Field :results.test_id is a required field."}"
Best Regards
npm keeps complaining that the testrail-api depends on a vulnerable version of request, which is a deprecated library. Are there any plans to migrate to another library like axios?
It looks like the addResultsForCases is missing case_id:
TestRail.prototype.addResultsForCases = function (run_id, data, callback) {
return this.apiPost('add_results_for_cases/' + run_id, JSON.stringify({ results: data }), callback);
};```
Should have been:
TestRail.prototype.addResultsForCases = function (run_id, case_id, data, callback) {
return this.apiPost('add_results_for_cases/' + run_id+'/'+case_id, JSON.stringify({ results: data }), callback);
};```
According to the docs:
"The difference to add_result is that this method expects a test run + test case instead of a test."
POST index.php?/api/v2/add_result_for_case/:run_id/:case_id
https://www.gurock.com/testrail/docs/api/reference/results#addresultforcase
Either the type definitions for addResults
and addResultsForCases
is incorrect, or the runtime implementation is incorrect:
testrail.addResultsForCases(1, [{
case_id: 1,
status_id: 1,
comment: 'This is an automated comment.'
elapsed: 0,
assignedto_id: 16
}])
// TypeScript is happy, but I get a 400: { message: { error: 'Field :results is a required field.' }
I think the type definitions make sense so the implementation would have to change to wrap data
with a results
wrapped:
TestRail.prototype.addResults = function (run_id, data, callback) {
return this.apiPost('add_results/' + run_id, JSON.stringify({ results: data }), callback);
};
TestRail.prototype.addResultsForCases = function (run_id, data, callback) {
return this.apiPost('add_results_for_cases/' + run_id, JSON.stringify({ results: data }), callback);
};
That change would probably break anyone using these methods and providing the results
wrapping manually.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.