@testkit/send-test-report
Version:
A simple utility to send CTRF-style test reports to Slack or Microsoft Teams via webhook.
16 lines (15 loc) • 531 B
JavaScript
import fetch from 'node-fetch';
export async function sendWebhook(webhookUrl, message, name) {
if (!webhookUrl) {
throw new Error(`${name} webhook URL is required.`);
}
const response = await fetch(webhookUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(message)
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`Failed to send ${name} report: ${response.status} ${errorText}`);
}
}