From 5268bb109fb51001ff8c24ac48674891259fbace Mon Sep 17 00:00:00 2001
From: ESTELLON Bertrand <bertrand.estellon@univ-amu.fr>
Date: Wed, 4 Dec 2024 14:03:14 +0000
Subject: [PATCH] Correction des tests du TD45

---
 TD45/all.test.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/TD45/all.test.js b/TD45/all.test.js
index c5737f9..13cef0b 100644
--- a/TD45/all.test.js
+++ b/TD45/all.test.js
@@ -69,7 +69,11 @@ if (progression >= 27) {
         const browser = await puppeteer.launch();
         const page = await browser.newPage();
         const consoleLogs = [];
-        page.on('console', async consoleObj => { consoleLogs.push(await consoleObj.args()[0]?.jsonValue()) });
+        page.on('console', async consoleObj => { 
+            const line = await consoleObj.args()[0]?.jsonValue();
+            if (line == undefined) return;
+            consoleLogs.push(line) 
+        });
         await page.goto(`http://localhost:${fastify.server.address().port}`);
         const content = await page.content();
         const dom = new JSDOM(content);
@@ -96,6 +100,7 @@ if (progression >= 28 && progression < 30) {
             const args = consoleObj.args();
             const arg0 = args[0];
             const json = await arg0.jsonValue();
+            if (json == undefined) return;
             consoleLogs.push(json) 
         });
         await page.goto(`http://localhost:${fastify.server.address().port}`);
@@ -122,6 +127,7 @@ if (progression == 29) {
             const args = consoleObj.args();
             const arg0 = args[0];
             const json = await arg0.jsonValue();
+            if (json == undefined) return;
             consoleLogs.push(json) 
         });
         await page.goto(`http://localhost:${fastify.server.address().port}`);
-- 
GitLab