Skip to content

Commit

Permalink
fix: clean up empty coverage reports directory
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed May 15, 2024
1 parent 1ec61ce commit c65b659
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
8 changes: 8 additions & 0 deletions test/coverage-test/option-tests/fixture.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Generic test fixture to generate some coverage

import { test } from 'vitest'
import { add } from '../src/utils'

test('cover some lines', () => {
add(1, 2)
})
21 changes: 20 additions & 1 deletion test/coverage-test/testing-options.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, rmSync, writeFileSync } from 'node:fs'
import { existsSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
import { startVitest } from 'vitest/node'

/**
Expand Down Expand Up @@ -147,6 +147,25 @@ const testCases = [
process.exitCode = 0
},
},
{
testConfig: {
name: 'remove empty coverages directory',
include: ['option-tests/fixture.test.ts'],
coverage: {
reporter: 'text',
all: false,
include: ['src/utils.ts'],
},
},
after() {
if (existsSync('./coverage')) {
if (readdirSync('./coverage').length !== 0)
throw new Error('Test case expected coverage directory to be empty')

throw new Error('Empty coverage directory was not cleaned')
}
},
},
]

for (const provider of ['v8', 'istanbul']) {
Expand Down

0 comments on commit c65b659

Please sign in to comment.