Repository navigation
Addon Vitest: Support Vitest 5 #36221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+1,737
−384
Closed
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
db9f4af
Addon Vitest: support Vitest 5 initialization, reporters and test names
PaulMest 1b3565a
Build: run local Storybook development and tests on Vitest 5
PaulMest 414e293
Addon Vitest: preserve initialization on older supported versions
PaulMest 1c66b5c
Addon Vitest: isolate generated Storybook projects from root test config
PaulMest 0568fab
chore: remove expired Vitest release-age exceptions
PaulMest 4982531
docs: clarify global coverage configuration for isolated projects
PaulMest e77f7f9
fix(addon-vitest): support Vitest 5 coverage reporter loading
PaulMest d936a5c
fix(addon-vitest): preserve shared Vite configuration
PaulMest b17ae39
test: fix core mocks for Vitest 5
PaulMest f73171b
chore: use caret ranges for Vitest 5 packages
PaulMest a16ead3
docs: clarify Vitest project isolation limits
PaulMest 567b645
test(addon-vitest): verify built coverage reporter loaders
PaulMest 0e516a3
test(vitest): exercise real cross-version browser lifecycles
PaulMest 0dfef13
fix(vitest): resolve browser APIs on Vitest 3
PaulMest f5883c0
fix(vitest): use current coverage watermarks after runner restarts
PaulMest c2bdce5
test(vitest): verify framework config migration and UI watch runs
PaulMest 5a5e7e9
test(vitest): add reproducible coverage and mutation measurements
PaulMest 3ea7355
test(vitest): type internal store preparation in compatibility harness
PaulMest b7d31f1
test(vitest): wait for watch cleanup before coverage tests
PaulMest fcad0e5
fix(vitest): align compatibility with the Storybook 11 Vitest floor
PaulMest db78da2
test(vitest): adapt compatibility harness to the latest store API
PaulMest 9e33b96
test(e2e): focus open dialogs before dismissing them
PaulMest 2ac499f
test(core): name type assertions for Vitest 5 collection
PaulMest bd87999
fix(angular-vite): initialize Angular 22.2 optimizer hashing
PaulMest ad28d8c
fix(angular-vite): require Analog with Angular 22 cache support
PaulMest b4344f5
test(e2e): reset live onboarding survey state between attempts
PaulMest 5682fed
Merge next and deduplicate Analog dependencies
PaulMest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,81 @@ | ||
| import { execFile } from 'node:child_process'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { promisify } from 'node:util'; | ||
|
|
||
| import { expect, it, vi } from 'vitest'; | ||
|
|
||
| import type { ReportNode } from 'istanbul-lib-report'; | ||
|
|
||
| import StorybookCoverageReporter from './coverage-reporter.ts'; | ||
| import type { TestManager } from './test-manager.ts'; | ||
|
|
||
| it.each([ | ||
| ['Vitest 3/4', "require('istanbul-reports').create"], | ||
| ['Vitest 5', "(await import('@vitest/istanbul-lib-report')).createAsync"], | ||
| ])('loads the built coverage reporter through the %s loader', async (_version, loader) => { | ||
| await expect( | ||
| promisify(execFile)( | ||
| process.execPath, | ||
| [ | ||
| '--input-type=module', | ||
| '--eval', | ||
| ` | ||
| import { strict as assert } from 'node:assert'; | ||
| import { createRequire } from 'node:module'; | ||
| const require = createRequire(import.meta.url); | ||
| const summaries = []; | ||
| const reporter = await (${loader})( | ||
| '@storybook/addon-vitest/internal/coverage-reporter', | ||
| { | ||
| testManager: { | ||
| onCoverageCollected: (summary) => summaries.push(summary), | ||
| vitestManager: { vitest: { config: { coverage: { watermarks: { statements: [50, 90] } } } } }, | ||
| }, | ||
| } | ||
| ); | ||
| reporter.onSummary({ | ||
| isRoot: () => true, | ||
| getCoverageSummary: () => ({ data: { statements: { pct: 87.4 } } }), | ||
| }); | ||
| assert.deepEqual(summaries, [{ percentage: 87, status: 'warning' }]); | ||
| `, | ||
| ], | ||
| { cwd: fileURLToPath(new URL('../../', import.meta.url)) } | ||
| ) | ||
| ).resolves.toMatchObject({ stdout: '' }); | ||
| }); | ||
|
|
||
| it.each([ | ||
| { percentage: 49, watermarks: [50, 90], expected: { percentage: 49, status: 'negative' } }, | ||
| { percentage: 50, watermarks: [50, 90], expected: { percentage: 50, status: 'warning' } }, | ||
| { percentage: 89.5, watermarks: [50, 90], expected: { percentage: 90, status: 'positive' } }, | ||
| { percentage: 79.4, watermarks: undefined, expected: { percentage: 79, status: 'warning' } }, | ||
| { percentage: 80, watermarks: [], expected: { percentage: 80, status: 'positive' } }, | ||
| { percentage: 60, watermarks: [60], expected: { percentage: 60, status: 'warning' } }, | ||
| ])( | ||
| 'reports $expected for $percentage with watermarks $watermarks', | ||
| ({ percentage, watermarks, expected }) => { | ||
| const onCoverageCollected = vi.fn(); | ||
| const testManager = { | ||
| onCoverageCollected, | ||
| vitestManager: { | ||
| vitest: { config: { coverage: { watermarks: { statements: watermarks } } } }, | ||
| }, | ||
| } as unknown as TestManager; | ||
| const reporter = new StorybookCoverageReporter({ testManager }); | ||
| reporter.onSummary({ | ||
| isRoot: () => true, | ||
| getCoverageSummary: () => ({ data: { statements: { pct: percentage } } }), | ||
| } as unknown as ReportNode); | ||
| expect(onCoverageCollected).toHaveBeenCalledExactlyOnceWith(expected); | ||
| } | ||
| ); | ||
|
|
||
| it('ignores nested coverage summaries', () => { | ||
| const onCoverageCollected = vi.fn(); | ||
| const reporter = new StorybookCoverageReporter({ | ||
| testManager: { onCoverageCollected } as unknown as TestManager, | ||
| }); | ||
| reporter.onSummary({ isRoot: () => false } as ReportNode); | ||
| expect(onCoverageCollected).not.toHaveBeenCalled(); | ||
| }); | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.