Top
23 Mai 2025
par Ayoub Elmenssouri
Share
1npm install @notionhq/client dotenv1import * as fs from "fs";2import * as dotenv from "dotenv";3import { Client } from "@notionhq/client";45dotenv.config();6const notion = new Client({ auth: process.env.NOTION_TOKEN });7const databaseId = process.env.NOTION_DB_ID;89async function sendReportToNotion() {10 try {11 const raw = fs.readFileSync("cypress-report.json", "utf8");12 const data = JSON.parse(raw);13 const stats = data.stats;14 const status = stats.failures > 0 ? "Failed" : "Passed";15 const environment = process.env.ENVIRONMENT || "staging";1617 await notion.pages.create({18 parent: { database_id: databaseId },19 properties: {20 Status: { select: { name: status } },21 Date: { date: { start: new Date().toISOString() } },22 Total_Tests: { number: stats.tests || 0 },23 Passed_Tests: { number: stats.passes || 0 },24 Failed_Tests: { number: stats.failures || 0 },25 Environment: { select: { name: environment } },26 },27 });28 } catch(error) {29 console.error("Erreur lors de l'envoi du rapport à Notion :", error);30 }31}3233sendReportToNotion();




Copyright © 2024 JumpIT
Tous droits réservés