-
-
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.
fix(coverage): warn if
vitest
and coverage versions don't match
- Loading branch information
1 parent
6e06278
commit 146a021
Showing
5 changed files
with
81 additions
and
4 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
50 changes: 50 additions & 0 deletions
50
test/coverage-test/test/mixed-versions-warning.unit.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,50 @@ | ||
import { expect, test, vi } from 'vitest' | ||
import { configDefaults } from 'vitest/config' | ||
import V8Provider from '@vitest/coverage-v8' | ||
import packageJson from '@vitest/coverage-v8/package.json' | ||
import IstanbulProvider from '@vitest/coverage-istanbul' | ||
import stripAnsi from 'strip-ansi' | ||
|
||
const version = packageJson.version | ||
|
||
test('v8 provider logs warning if versions do not match', async () => { | ||
const provider = await V8Provider.getProvider() | ||
const warn = vi.fn() | ||
|
||
provider.initialize({ | ||
version: '1.0.0', | ||
logger: { warn }, | ||
config: configDefaults, | ||
} as any) | ||
|
||
expect(warn).toHaveBeenCalled() | ||
|
||
const message = warn.mock.calls[0][0] | ||
|
||
expect(stripAnsi(message)).toMatchInlineSnapshot(` | ||
"Loaded vitest@1.0.0 and @vitest/coverage-v8@${version} . | ||
Running mixed versions is not supported and may lead into bugs | ||
Update your dependencies and make sure the versions match." | ||
`) | ||
}) | ||
|
||
test('istanbul provider logs warning if versions do not match', async () => { | ||
const provider = await IstanbulProvider.getProvider() | ||
const warn = vi.fn() | ||
|
||
provider.initialize({ | ||
version: '1.0.0', | ||
logger: { warn }, | ||
config: configDefaults, | ||
} as any) | ||
|
||
expect(warn).toHaveBeenCalled() | ||
|
||
const message = warn.mock.calls[0][0] | ||
|
||
expect(stripAnsi(message)).toMatchInlineSnapshot(` | ||
"Loaded vitest@1.0.0 and @vitest/coverage-istanbul@${version} . | ||
Running mixed versions is not supported and may lead into bugs | ||
Update your dependencies and make sure the versions match." | ||
`) | ||
}) |