This example fetches failed test results from TestCollab and creates a Trello card for each one.
Steps involved:
-
Fetching details of test cases that have failed under a test plan that are assigned to a particular tester in TestCollab
Posting an issue in Trello on basis of test case details fetched
Assumptions
-
An API token has been generated in TestCollab for a user who has rights to read the relevant project's test plan results
-
A Trello API key and API token have been acquired, and you know the ID of the Trello list that should receive the cards
Load the values used below from your CI provider or operating system's secret manager. Do not
commit a .env file containing these credentials.
Here is the sample code:
const axios = require("axios");
function requireEnv(name) {
const value = process.env[name];
if (!value) throw new Error(`Missing required environment variable: ${name}`);
return value;
}
const config = {
testcollabToken: requireEnv("TESTCOLLAB_TOKEN"),
projectId: Number(requireEnv("TESTCOLLAB_PROJECT_ID")),
testPlanId: Number(requireEnv("TESTCOLLAB_TEST_PLAN_ID")),
assigneeId: Number(requireEnv("TESTCOLLAB_ASSIGNEE_ID")),
trelloToken: requireEnv("TRELLO_API_TOKEN"),
trelloKey: requireEnv("TRELLO_API_KEY"),
trelloListId: requireEnv("TRELLO_LIST_ID"),
};
async function reportDefects() {
const response = await axios.get("https://api.testcollab.io/executedtestcases", {
params: {
token: config.testcollabToken,
project: config.projectId,
test_plan: config.testPlanId,
status: 2,
assigned_to: config.assigneeId,
},
});
for (const testCase of response.data) {
const title = `${testCase.test_case_revision.title} (id: ${testCase.id}) failed`;
const description = "Build a description from the failed steps and safe attachment links.";
const card = await axios.post("https://api.trello.com/1/cards", null, {
params: {
idList: config.trelloListId,
key: config.trelloKey,
token: config.trelloToken,
name: title,
desc: description,
},
});
console.log(`Created Trello card ${card.data.id}`);
}
}
reportDefects().catch(() => {
console.error("The defect integration failed. Check the service logs without printing tokens.");
process.exitCode = 1;
});
Important: Some APIs carry tokens and test data in query parameters. Do not log complete request URLs, Axios request configuration, or raw error objects.


