Jelajahi Sumber

unit tests results

sebavan 6 tahun lalu
induk
melakukan
dc8ae5e357
3 mengubah file dengan 20 tambahan dan 2 penghapusan
  1. 5 0
      azure-pipelines.yml
  2. 3 2
      package.json
  3. 12 0
      tests/unit/karma.conf.js

+ 5 - 0
azure-pipelines.yml

@@ -87,6 +87,11 @@ jobs:
   - script: 'gulp tests-babylon-unit'
     workingDirectory: Tools/Gulp
     displayName: 'Unit Tests'
+  - task: PublishTestResults@2
+    condition: succeededOrFailed()
+    inputs:
+      testRunner: JUnit
+      testResultsFiles: '.temp/testResults/UnitTests.xml'
   - script: |
       export DISPLAY=:99
       Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &

+ 3 - 2
package.json

@@ -70,11 +70,12 @@
         "gulp-tslint": "^8.1.3",
         "gulp-typedoc": "^2.2.1",
         "gulp-typescript": "4.0.2",
-        "karma": "^3.1.1",
+        "karma": "^4.0.1",
         "karma-browserstack-launcher": "^1.4.0",
         "karma-chai": "^0.1.0",
         "karma-chrome-launcher": "^2.2.0",
         "karma-firefox-launcher": "^1.1.0",
+        "karma-junit-reporter": "^1.2.0",
         "karma-mocha": "^1.3.0",
         "karma-sinon": "^1.0.5",
         "merge2": "~1.2.2",
@@ -105,4 +106,4 @@
         "webpack-stream": "5.0.0",
         "xhr2": "^0.1.4"
     }
-}
+}

+ 12 - 0
tests/unit/karma.conf.js

@@ -48,6 +48,18 @@ module.exports = function (config) {
         // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
         logLevel: config.LOG_INFO,
 
+        reporters: ['progress', 'junit'],
+
+        junitReporter: {
+            outputDir: '.temp/testResults', // results will be saved as $outputDir/$browserName.xml
+            outputFile: 'UnitTests.xml', // if included, results will be saved as $outputDir/$browserName/$outputFile
+            suite: 'Unit Tests', // suite will become the package name attribute in xml testsuite element
+            useBrowserName: false, // add browser name to report and classes names
+            nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
+            classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
+            properties: {} // key value pair of properties to add to the <properties> section of the report
+        },
+
         browsers: ['ChromeHeadless']
     })
 }