-
Notifications
You must be signed in to change notification settings - Fork 72
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
fix: Fixed sync issue #264
Conversation
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## next #264 +/- ##
=======================================
Coverage 76.66% 76.66%
=======================================
Files 11 11
Lines 180 180
Branches 40 40
=======================================
Hits 138 138
Misses 42 42
☔ View full report in Codecov by Sentry. |
This reverts commit 4aadf17.
Add pageerror listener and handler in transformPlaywright to capture errors occurring during page.evaluate. Also add off listener before returning the result.
Update tests to use more concise assertions and better test coverage.
This is super awesome @bryanjtc, thanks for finding an alternative that does not affect performance!!! 🙌 Unfortunately I think there's still something going on. Let me show a few use cases where I noticed issues: 1. Error thrown on click: export const Demo = (args) => (
<button type="button" onClick={() => { throw new Error('boom') }}>
Click
</button>
); Even though there is only one failure, it's logged as if there were many failures: 2. Failing play function: export const Demo = (args) => (
<button type="button" onClick={() => args.onSubmit('clicked')}>
Click
</button>
);
Demo.play = async ({ args, canvasElement }) => {
await userEvent.click(within(canvasElement).getByRole('alert')); // this will fail, it's supposed to be button
await expect(args.onSubmit).toHaveBeenCalledWith(expect.stringMatching(/([A-Z])\w+/gi));
}; Even though the play function is wrong and fails: The test-runner detects it as success, just logging the failure as a console.error message instead: Do you have any idea what's going on? |
Co-authored-by: Yann Braga <yannbf@gmail.com>
Investigating |
Hey @bryanjtc did you manage to find anything new? Thanks! |
Due to my ongoing commitments, I haven't had a chance to review it yet. However, I anticipate having more availability in about a month. During that time, I'll make it a priority and provide a timely update. |
You're the best! <3 |
Errors identified in the modified Component Demo for case 1: Error thrown on click
Errors 1 and 3 are expected. Looking into catching error 2. |
For now, I think we should show the 3 errors, based on this discussion. https://stackoverflow.com/a/74350185. |
} catch (error) { | ||
throw error; | ||
result = null; | ||
} |
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.
If we're just catching and throwing the error, does it make sense to wrap it in a try catch? in this case, result = null
will never be called because the error is thrown before that line
This PR was superceeded by #404 |
Fixes: #62
How to test: Modify Button.stories.js
Demo
story like thisSummary
This pull request addresses a problem with the test runner for Storybook where errors in one test (specifically the "demo" story in this case) were leaking and affecting subsequent tests (the "findme" story).
The root cause of this issue was identified as improper error handling in the transformPlaywright.ts file. To mitigate this, we have encapsulated the test function in a try-catch block to handle potential errors, and introduced a mechanism to ensure page errors are properly deregistered after each test execution.
Here's a brief summary of the changes:
page.evaluate
call within a try-catch block to handle errors.pageErrorListener
as a separate function so that it can be used to deregister from page errors after each test.page.off('pageerror', pageErrorListener);
to deregister from page errors after each test.page.evaluate
.📦 Published PR as canary version:
0.13.1--canary.264.c65968e.0
✨ Test out this PR locally via:
npm install @storybook/test-runner@0.13.1--canary.264.c65968e.0 # or yarn add @storybook/test-runner@0.13.1--canary.264.c65968e.0