-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Addon Test: Improve unhandled error messages #30755
base: next
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
setTimeout(unhandledRejection, 0); | ||
} else if (errorType === 'error') { | ||
setTimeout(unhandledError, 0); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: setTimeout with 0 delay may be flaky in tests. Consider using queueMicrotask() or Promise.resolve() for more reliable async behavior
const error = e as VitestError; | ||
const origin = getErrorOrigin(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Type assertion could fail if e is not actually a VitestError. Consider adding a type guard or handling non-VitestError cases.
error.message = `${error.message}\n${origin}`; | ||
error.stack = `${error.stack}\n${origin}`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Stack trace could be undefined. Need null check before concatenation.
error.message = `${error.message}\n${origin}`; | |
error.stack = `${error.stack}\n${origin}`; | |
} | |
error.message = `${error.message}\n${origin}`; | |
if (error.stack) error.stack = `${error.stack}\n${origin}`; | |
} |
View your CI Pipeline Execution ↗ for commit 9aa6637.
☁️ Nx Cloud last updated this comment at |
43567a9
to
3442715
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments, but looks good! ✨
unhandledErrors.forEach((e: unknown) => { | ||
const error = e as VitestError; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unhandledErrors.forEach((e: unknown) => { | |
const error = e as VitestError; | |
unhandledErrors.forEach((error: VitestError) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that will cause type failures because the types don't match :<
we rely on internal stuff for this solution
await expect(errorLink).toContainText('2 unhandled errors', { timeout: 30000 }); | ||
await errorLink.click(); | ||
|
||
await expect(page.locator('pre')).toContainText('I THREW AN UNHANDLED ERROR!'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't the important bit of this test, that it actually outputs the correct path, and so shouldn't we assert on that?
Because it's an absolute path it's going to be different per environment, but then at least just assert that it contains the story file name?
@@ -30,7 +30,7 @@ export default defineWorkspace([ | |||
}] | |||
}, | |||
setupFiles: ["./.storybook/vitest.setup.ts"], | |||
environment: "happy-dom", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this change necessary?
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
Before | After | Difference | |
---|---|---|---|
Dependency count | 3 | 51 | 🚨 +48 🚨 |
Self size | 445 KB | 445 KB | 🚨 +44 B 🚨 |
Dependency size | 2.81 MB | 12.05 MB | 🚨 +9.24 MB 🚨 |
Bundle Size Analyzer | Link | Link |
@storybook/addon-interactions
Before | After | Difference | |
---|---|---|---|
Dependency count | 5 | 51 | 🚨 +46 🚨 |
Self size | 129 KB | 129 KB | 🚨 +62 B 🚨 |
Dependency size | 3.11 MB | 12.07 MB | 🚨 +8.96 MB 🚨 |
Bundle Size Analyzer | Link | Link |
@storybook/addon-test
Before | After | Difference | |
---|---|---|---|
Dependency count | 9 | 55 | 🚨 +46 🚨 |
Self size | 844 KB | 845 KB | 🚨 +778 B 🚨 |
Dependency size | 4.56 MB | 13.52 MB | 🚨 +8.96 MB 🚨 |
Bundle Size Analyzer | Link | Link |
storybook
Before | After | Difference | |
---|---|---|---|
Dependency count | 98 | 51 | 🎉 -47 🎉 |
Self size | 21.54 MB | 19.64 MB | 🎉 -1.90 MB 🎉 |
Dependency size | 21.69 MB | 14.26 MB | 🎉 -7.43 MB 🎉 |
Bundle Size Analyzer | Link | Link |
@storybook/experimental-nextjs-vite
Before | After | Difference | |
---|---|---|---|
Dependency count | 141 | 167 | 🚨 +26 🚨 |
Self size | 215 KB | 215 KB | 🚨 +77 B 🚨 |
Dependency size | 39.37 MB | 31.38 MB | 🎉 -7.98 MB 🎉 |
Bundle Size Analyzer | Link | Link |
@storybook/nextjs
Before | After | Difference | |
---|---|---|---|
Dependency count | 540 | 572 | 🚨 +32 🚨 |
Self size | 218 KB | 218 KB | 🚨 +57 B 🚨 |
Dependency size | 58.82 MB | 66.13 MB | 🚨 +7.31 MB 🚨 |
Bundle Size Analyzer | Link | Link |
@storybook/react-vite
Before | After | Difference | |
---|---|---|---|
Dependency count | 122 | 124 | 🚨 +2 🚨 |
Self size | 15 KB | 15 KB | 🚨 +127 B 🚨 |
Dependency size | 20.46 MB | 20.48 MB | 🚨 +12 KB 🚨 |
Bundle Size Analyzer | Link | Link |
sb
Before | After | Difference | |
---|---|---|---|
Dependency count | 99 | 52 | 🎉 -47 🎉 |
Self size | 1 KB | 1 KB | 0 B |
Dependency size | 43.24 MB | 33.90 MB | 🎉 -9.34 MB 🎉 |
Bundle Size Analyzer | Link | Link |
@storybook/cli
Before | After | Difference | |
---|---|---|---|
Dependency count | 388 | 356 | 🎉 -32 🎉 |
Self size | 282 KB | 284 KB | 🚨 +2 KB 🚨 |
Dependency size | 93.24 MB | 84.40 MB | 🎉 -8.83 MB 🎉 |
Bundle Size Analyzer | Link | Link |
@storybook/codemod
Before | After | Difference | |
---|---|---|---|
Dependency count | 309 | 274 | 🎉 -35 🎉 |
Self size | 614 KB | 617 KB | 🚨 +3 KB 🚨 |
Dependency size | 74.84 MB | 65.99 MB | 🎉 -8.85 MB 🎉 |
Bundle Size Analyzer | Link | Link |
Closes #30754
What I did
This change is currently blocked as it needs a new version of Vitest to be released. Until then, the E2E tests will fail.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>
Greptile Summary
Enhanced error reporting for unhandled errors in Storybook's Addon Test framework, adding detailed context about error origins and improving test coverage.
UnhandledErrors.stories.tsx
to demonstrate error handling with both synchronous and asynchronous unhandled errorsreporter.ts
to include file paths and test names in error messages via newgetErrorOrigin
functioncomponent-testing.spec.ts
to verify unhandled error reportingvitest.workspace.ts
for better error handling support