Skip to content

Commit

Permalink
Setup test report and publish test result (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
EzioLi01 authored Feb 7, 2023
1 parent bc1dea9 commit ffec401
Show file tree
Hide file tree
Showing 5 changed files with 281 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .ci/common-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ steps:
displayName: "Run unit tests"
env:
DISPLAY: ":99.0"

- task: PublishTestResults@2
displayName: "Publish Test Results"
inputs:
testResultsFiles: test/simulateTestReport.xml
failTaskOnFailedTests: true
testRunTitle: "$(Agent.OS) Cordova simulate unit tests - Attempt №$(System.JobAttempt)"
condition: always()
255 changes: 255 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
"husky": "^8.0.2",
"in-publish": "^2.0.0",
"mocha": "^10.2.0",
"mocha-junit-reporter": "^2.2.0",
"mocha-multi-reporters": "^1.5.1",
"mstranslator": "^3.0.0",
"parse5": "^2.2.1",
"pretty-data": "^0.40.0"
Expand All @@ -60,6 +62,6 @@
"update-loc": "node ./tools/i18n/update",
"eslint": "npx eslint .",
"prepare": "husky install",
"test": "mocha --ui tdd ./test/*.js --timeout 100000"
"test": "mocha ./test/*.js --ui tdd --timeout 100000 --reporter mocha-multi-reporters --reporter-options configFile=./test/mochaReporterConfig.json"
}
}
6 changes: 6 additions & 0 deletions test/mochaReporterConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, mocha-junit-reporter",
"mochaJunitReporterReporterOptions": {
"mochaFile": "./test/simulateTestReport.xml"
}
}
9 changes: 9 additions & 0 deletions test/simulateTestReport.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="0.010" tests="1" failures="0">
<testsuite name="Root Suite" timestamp="2023-02-07T04:57:43" tests="0" time="0.000" failures="0">
</testsuite>
<testsuite name="simulatorProcess" timestamp="2023-02-07T04:57:43" tests="1" file="D:\cordova-simulate\test\simulator.test.js" time="0.007" failures="0">
<testcase name="simulatorProcess After simulator init, simulator.state should be IDLE" time="0.005" classname="After simulator init, simulator.state should be IDLE">
</testcase>
</testsuite>
</testsuites>

0 comments on commit ffec401

Please sign in to comment.