EnricoMi / publish-unit-test-result-action

GitHub Action to publish unit test results on GitHub
Apache License 2.0
593 stars 177 forks source link

Wrong duration using Mocha and the JSON reporter #472

Open lieser opened 1 year ago

lieser commented 1 year ago

The JSON reporter included in Mocha reports the duration in seconds. The action assumes seconds however, resulting in a wrong duration in the published test results.

If the JSON file from Dart is using the same format but seconds for the duration, maybe it would be possible to use the difference between the included start and end as a hint for the unit of duration?

Example workflow with the issue: https://github.com/lieser/dkim_verifier/actions/runs/5306139976/jobs/9603566014

{
  "stats": {
    "suites": 72,
    "tests": 236,
    "passes": 233,
    "pending": 3,
    "failures": 0,
    "start": "2023-06-18T22:56:22.292Z",
    "end": "2023-06-18T22:56:24.033Z",
    "duration": 1741
  },
  "tests": [
    //...
  ]
}

grafik

EnricoMi commented 1 year ago

Good idea to detect the duration unit. I guess the unit does not change between runs of a workflow, so I guess setting time_unit: milliseconds should work here. See `Options related to reporting test results' section in README.md.

lieser commented 1 year ago

Thanks for pointing me to the time unit setting, missed that. Works without a problem now, so the issue can be closed from my site.

Would of course still be nice if it could automatically detect the correct unit.