Skip to content

Commit

Permalink
fix: add better failover case for duration not being found (#17)
Browse files Browse the repository at this point in the history
* fix: add better failover case for duration not being found

* Update src/xml.ts

Co-authored-by: Ari Perkkiö <ari.perkkio@gmail.com>

* test: update snapshots

Co-authored-by: Ari Perkkiö <ari.perkkio@gmail.com>
  • Loading branch information
BobGneu and AriPerkkio committed Jul 13, 2022
1 parent 9003c35 commit 452ab59
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/xml.ts
Expand Up @@ -117,8 +117,8 @@ function getAllTests(task: Task): Test[] {
function getDurationAttribute(test: Test): string {
const duration = test.result?.duration;

if (typeof duration !== 'number') {
return '';
if (typeof duration !== "number") {
return ` duration="0"`;
}

return ` duration="${Math.round(duration)}"`;
Expand Down
6 changes: 3 additions & 3 deletions test/index.test.ts
Expand Up @@ -26,7 +26,7 @@ test('writes a report', () => {
"<testExecutions version=\\"1\\">
<file path=\\"test/fixtures/animals.test.ts\\">
<testCase name=\\"animals - dogs say woof\\" duration=\\"123\\" />
<testCase name=\\"animals - figure out what rabbits say\\">
<testCase name=\\"animals - figure out what rabbits say\\" duration=\\"123\\">
<skipped message=\\"figure out what rabbits say\\" />
</testCase>
<testCase name=\\"animals - flying ones - cat can fly\\" duration=\\"123\\">
Expand Down Expand Up @@ -80,10 +80,10 @@ test('writes a report', () => {
at async withEnv (<process-cwd>/node_modules/vitest/dist/vendor-entry.78de67ab.mjs:171:5)]]>
</error>
</testCase>
<testCase name=\\"math - random numbers are unstable\\">
<testCase name=\\"math - random numbers are unstable\\" duration=\\"123\\">
<skipped message=\\"random numbers are unstable\\" />
</testCase>
<testCase name=\\"math - learn square roots\\">
<testCase name=\\"math - learn square roots\\" duration=\\"123\\">
<skipped message=\\"learn square roots\\" />
</testCase>
<testCase name=\\"math - divide - basic\\" duration=\\"123\\" />
Expand Down

0 comments on commit 452ab59

Please sign in to comment.