Просмотр исходного кода

modification de karma pour le test

DESKTOP-SMCIPAV\falko 4 месяцев назад
Родитель
Сommit
362ec3e8c3
2 измененных файлов с 52 добавлено и 11 удалено
  1. 2 9
      Jenkinsfile
  2. 50 2
      angular-client/karma.conf.js

+ 2 - 9
Jenkinsfile

@@ -40,7 +40,7 @@ pipeline {
         }
         }
 
 
         // 2. Installation des dépendances et tests unitaires Angular
         // 2. Installation des dépendances et tests unitaires Angular
-    stage('Unit Tests') {
+   stage('Unit Tests') {
   agent {
   agent {
     docker {
     docker {
       image 'cypress/browsers:node14.17.0-chrome91-ff89'
       image 'cypress/browsers:node14.17.0-chrome91-ff89'
@@ -50,26 +50,19 @@ pipeline {
   environment {
   environment {
     CHROME_BIN = '/usr/bin/google-chrome'
     CHROME_BIN = '/usr/bin/google-chrome'
     NODE_OPTIONS = '--max-old-space-size=4096'
     NODE_OPTIONS = '--max-old-space-size=4096'
-    DISPLAY = ':99'
   }
   }
   steps {
   steps {
     dir('angular-client') {
     dir('angular-client') {
       sh '''
       sh '''
-        echo "🔧 Configuration de l'environnement"
-        export DISPLAY=:99
-        Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
-
         echo "✅ Installation des dépendances"
         echo "✅ Installation des dépendances"
         npm install --legacy-peer-deps
         npm install --legacy-peer-deps
 
 
         echo "🚀 Lancement des tests"
         echo "🚀 Lancement des tests"
-        # Utiliser ChromeHeadlessCustom au lieu de ChromeHeadless
-        npx ng test --no-watch --no-progress --browsers=ChromeHeadlessCustom
+        npx ng test --no-watch --no-progress --browsers=ChromeHeadlessCI
       '''
       '''
     }
     }
   }
   }
 }
 }
-
         // 3. Analyse SonarQube pour la qualité du code
         // 3. Analyse SonarQube pour la qualité du code
         // stage('SonarQube Analysis') {
         // stage('SonarQube Analysis') {
         //     steps {
         //     steps {

+ 50 - 2
angular-client/karma.conf.js

@@ -33,6 +33,54 @@ module.exports = function (config) {
     captureTimeout: 60000,
     captureTimeout: 60000,
     browserDisconnectTimeout: 60000,
     browserDisconnectTimeout: 60000,
     browserDisconnectTolerance: 3,
     browserDisconnectTolerance: 3,
-    browserNoActivityTimeout: 60000
+    browserNoActivityTimeout: 60000,
+
+    // Custom launcher configurations ajoutées pour Jenkins CI
+    customLaunchers: {
+      ChromeHeadlessCustom: {
+        base: 'ChromeHeadless',
+        flags: [
+          '--no-sandbox',
+          '--disable-web-security',
+          '--disable-features=VizDisplayCompositor',
+          '--disable-gpu',
+          '--disable-canvas-aa',
+          '--disable-3d-apis',
+          '--disable-extensions',
+          '--disable-dev-shm-usage',
+          '--disable-translate',
+          '--disable-logging',
+          '--disable-background-timer-throttling',
+          '--disable-backgrounding-occluded-windows',
+          '--disable-renderer-backgrounding',
+          '--remote-debugging-port=9222'
+        ]
+      },
+      ChromeHeadlessCI: {
+        base: 'ChromeHeadless',
+        flags: [
+          '--no-sandbox',                    // CRUCIAL pour Docker/Jenkins
+          '--disable-web-security',
+          '--disable-features=VizDisplayCompositor',
+          '--disable-gpu',
+          '--disable-canvas-aa',
+          '--disable-3d-apis',
+          '--disable-extensions',
+          '--disable-dev-shm-usage',        // Important pour les environnements Docker
+          '--disable-translate',
+          '--disable-logging',
+          '--disable-background-timer-throttling',
+          '--disable-backgrounding-occluded-windows',
+          '--disable-renderer-backgrounding',
+          '--remote-debugging-port=9222',
+          '--headless',
+          '--disable-ipc-flooding-protection',
+          '--disable-hang-monitor',
+          '--disable-prompt-on-repost',
+          '--disable-default-apps',
+          '--virtual-time-budget=5000'      // Timeout virtuel pour CI
+        ]
+      }
+    }
   });
   });
-};
+};