-
-
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.
test(coverage): option specific test setup
- Loading branch information
1 parent
0ff798a
commit 5df6aa4
Showing
10 changed files
with
114 additions
and
275 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
20 changes: 20 additions & 0 deletions
20
test/coverage-test/coverage-report-tests/allow-external.test.ts
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,20 @@ | ||
import fs from 'node:fs' | ||
import { expect, test } from 'vitest' | ||
|
||
const allowExternal = import.meta.env.VITE_COVERAGE_ALLOW_EXTERNAL | ||
|
||
test.skipIf(!allowExternal)('{ allowExternal: true } includes files outside project root', async () => { | ||
expect(fs.existsSync('./coverage/test-utils/fixtures/math.ts.html')).toBe(true) | ||
|
||
// Files inside project root should always be included | ||
expect(fs.existsSync('./coverage/coverage-test/src/utils.ts.html')).toBe(true) | ||
}) | ||
|
||
test.skipIf(allowExternal)('{ allowExternal: false } excludes files outside project root', async () => { | ||
expect(fs.existsSync('./coverage/test-utils/fixtures/math.ts.html')).toBe(false) | ||
expect(fs.existsSync('./test-utils/fixtures/math.ts.html')).toBe(false) | ||
expect(fs.existsSync('./fixtures/math.ts.html')).toBe(false) | ||
|
||
// Files inside project root should always be included | ||
expect(fs.existsSync('./coverage/utils.ts.html')).toBe(true) | ||
}) |
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,12 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
import { multiply } from '../src/utils' | ||
import * as ExternalMath from '../../test-utils/fixtures/math' | ||
|
||
test('calling files outside project root', () => { | ||
expect(ExternalMath.sum(2, 3)).toBe(5) | ||
}) | ||
|
||
test('multiply - add some files to report', () => { | ||
expect(multiply(2, 3)).toBe(6) | ||
}) |
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
Oops, something went wrong.