Registry / communication / teams-ctrf

teams-ctrf

JSON →
library0.0.6jsnpmunverified

teams-ctrf is a utility designed to send structured test result notifications to Microsoft Teams channels, adhering to the Common Test Report Format (CTRF) specification. This package allows teams to automate the reporting of test execution outcomes, including summaries, detailed reports, and flaky test detection, directly into their Teams environment. It is currently in active development, with version `0.0.6` being the stable release, and `0.0.7-next` actively introducing new features and refinements. The project is part of the broader CTRF ecosystem, which aims to standardize test reporting across various testing frameworks and programming languages, providing a unified JSON format for consistent analysis and comparison. It stands out by integrating directly with the CTRF standard, offering both command-line and programmatic interfaces for flexible deployment in CI/CD pipelines.

npm install teams-ctrf
INSTALL
IMPORT
SIG · TEAMS-CTRF
T
teams-ctrf
communicationjavascriptv0.0.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sendTeamsMessage
import { sendTeamsMessage } from 'teams-ctrf';
const sendTeamsMessage = require('teams-ctrf').sendTeamsMessage;
This is the primary function for sending a basic test results message to Teams. Primarily designed for ESM, but CJS can access via `.default` or property access.
sendAdaptiveCard
import { sendAdaptiveCard } from 'teams-ctrf';
import sendAdaptiveCard from 'teams-ctrf/adaptive-card';
Use this function to send a more richly formatted Adaptive Card based on CTRF data. Adaptive Cards offer greater flexibility in layout and interactive elements.
cli
npx teams-ctrf results /path/to/ctrf-report.json
import { cli } from 'teams-ctrf';
The package offers a robust CLI for direct usage in CI/CD. Programmatic access to CLI functions is not directly exposed for import.

Demonstrates how to programmatically send a CTRF report as an Adaptive Card to Microsoft Teams using a webhook URL.

import { sendAdaptiveCard } from 'teams-ctrf'; const sampleCtrfReport = { id: 'report-123', name: 'Example Test Run', description: 'A sample CTRF report for quickstart.', results: { summary: { tests: 10, passed: 7, failed: 3, skipped: 0, pending: 0, other: 0, duration: 120000 // milliseconds }, testSuites: [ { id: 'suite-1', name: 'Authentication Tests', tests: [ { id: 'test-1', name: 'Login with valid credentials', status: 'passed', duration: 1000 }, { id: 'test-2', name: 'Login with invalid credentials', status: 'failed', duration: 500 } ] } ] }, metadata: { timestamp: new Date().toISOString() } }; const teamsWebhookUrl = process.env.TEAMS_WEBHOOK_URL ?? ''; if (!teamsWebhookUrl) { console.error('TEAMS_WEBHOOK_URL environment variable is not set.'); process.exit(1); } async function sendReportToTeams() { try { console.log('Sending Adaptive Card report to Teams...'); await sendAdaptiveCard(teamsWebhookUrl, sampleCtrfReport); console.log('Adaptive Card report sent successfully!'); } catch (error) { console.error('Failed to send Adaptive Card report:', error.message); process.exit(1); } } sendReportToTeams();
teams-ctrf --version
Debug
Known issues
breakingThe `0.0.7-next-4` release notes mention a "migration from Message". This indicates a significant change in how messages are structured and sent, potentially impacting users relying on previous default message formats or direct message object construction. Users upgrading to `0.0.7` (or newer `next` versions) should review the latest documentation for changes in message payload or the introduction of Adaptive Cards as a preferred format.
fix
Review the updated API for programmatic message sending. If custom message formats were used, they might need to be refactored to align with the new Adaptive Card structure or utilize the dedicated `sendAdaptiveCard` function for richer formatting. The CLI might also have new options like `--useAdaptiveCard`.
affects: >=0.0.7-next
gotchaProperly setting up a Microsoft Teams Incoming Webhook URL is crucial. Incorrect URLs or those lacking appropriate permissions will result in delivery failures without clear error messages from Teams itself.
fix
Ensure the `TEAMS_WEBHOOK_URL` environment variable (or directly provided URL) is correctly configured in your Microsoft Teams channel settings. Verify it's an 'Incoming Webhook' connector and has not been revoked. Test the webhook using a simple `curl` command if issues persist.
affects: >=0.0.1
Errors
Common errors & fixes
Error: Failed to send message to Teams: Invalid webhook URL or network error.
The provided Microsoft Teams webhook URL is either malformed, expired, or the system attempting to send the message has no network access to it.
fix
Double-check the `TEAMS_WEBHOOK_URL` for typos. Ensure your CI/CD environment or local machine has outbound internet access to the Teams webhook endpoint. Regenerate the webhook URL in Teams if necessary.
Failed to send Adaptive Card report: Error: Response status: 400. Response body: Bad payload
The CTRF report JSON or the Adaptive Card payload generated from it is malformed or does not adhere to the expected schema by Microsoft Teams.
fix
Validate your CTRF report JSON against the CTRF schema. If customizing the Adaptive Card, ensure its JSON structure is valid according to the Adaptive Cards schema (schema.adaptivecards.io). Minor differences in required fields or data types can cause this error.
TEAMS_WEBHOOK_URL environment variable is not set.
The required environment variable `TEAMS_WEBHOOK_URL` was not found during execution, which is necessary for the library to know where to send messages.
fix
Set the `TEAMS_WEBHOOK_URL` environment variable in your shell or CI/CD pipeline configuration. For example: `export TEAMS_WEBHOOK_URL='https://hooks.teams.com/services/your/webhook/url'` (replace with your actual URL).
Upgrade
Version history
0.0.6latest on npm
Audit
Dependencies
ctrfrequiredProvides the Common Test Report Format (CTRF) specification and utilities for report processing.
Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
1
Resources
teams-ctrf — npm install teams-ctrf · libregistry