-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(coverage): add
--exclude-after-remap
(#6309)
- Loading branch information
1 parent
34199bd
commit 5932a7f
Showing
6 changed files
with
105 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { expect } from 'vitest' | ||
import { coverageTest, normalizeURL, readCoverageMap, runVitest, test } from '../utils.js' | ||
import * as transpiled from '../fixtures/src/pre-bundle/bundle.js' | ||
|
||
test('{ excludeAfterRemap: true } should exclude files that come up after remapping', async () => { | ||
await runVitest({ | ||
include: [normalizeURL(import.meta.url)], | ||
coverage: { | ||
include: ['fixtures/src/**'], | ||
exclude: ['fixtures/src/pre-bundle/second.ts'], | ||
excludeAfterRemap: true, | ||
reporter: 'json', | ||
all: false, | ||
}, | ||
}) | ||
|
||
const coverageMap = await readCoverageMap() | ||
const files = coverageMap.files() | ||
|
||
expect(files).toMatchInlineSnapshot(` | ||
[ | ||
"<process-cwd>/fixtures/src/pre-bundle/first.ts", | ||
] | ||
`) | ||
}) | ||
|
||
test('{ excludeAfterRemap: false } should not exclude files that come up after remapping', async () => { | ||
await runVitest({ | ||
include: [normalizeURL(import.meta.url)], | ||
coverage: { | ||
include: ['fixtures/src/**'], | ||
exclude: ['fixtures/src/pre-bundle/second.ts'], | ||
reporter: 'json', | ||
all: false, | ||
}, | ||
}) | ||
|
||
const coverageMap = await readCoverageMap() | ||
const files = coverageMap.files() | ||
|
||
expect(files).toMatchInlineSnapshot(` | ||
[ | ||
"<process-cwd>/fixtures/src/pre-bundle/first.ts", | ||
"<process-cwd>/fixtures/src/pre-bundle/second.ts", | ||
] | ||
`) | ||
}) | ||
|
||
test('{ excludeAfterRemap: true } should exclude uncovered files that come up after remapping', async () => { | ||
await runVitest({ | ||
include: ['fixtures/test/math.test.ts'], | ||
coverage: { | ||
include: ['fixtures/src/pre-bundle/**'], | ||
exclude: ['fixtures/src/pre-bundle/second.ts'], | ||
excludeAfterRemap: true, | ||
reporter: 'json', | ||
all: true, | ||
}, | ||
}) | ||
|
||
const coverageMap = await readCoverageMap() | ||
const files = coverageMap.files() | ||
|
||
expect(files).contains('<process-cwd>/fixtures/src/pre-bundle/first.ts') | ||
expect(files).not.contains('<process-cwd>/fixtures/src/pre-bundle/second.ts') | ||
}) | ||
|
||
coverageTest('run bundled sources', () => { | ||
expect(transpiled.first.covered()).toBe('First') | ||
expect(transpiled.second.covered()).toBe('Second') | ||
}) |