-
Notifications
You must be signed in to change notification settings - Fork 33
fix!: align target and baseElement options with testing-library
#325
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
Conversation
mcous
commented
Feb 16, 2024
@yanick let me know if you think this is too much to change in one PR; I can split it up into a few separate changes relatively trivially
@yanick
yanick
left a comment
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.
Looks good! Can you also prepare a branch for the documentation changes related to this PR?
mcous
commented
Feb 16, 2024
10-4, will undraft this PR when corresponding docs PR is up
mcous
commented
Feb 17, 2024
Docs PR up at testing-library/testing-library-docs#1369
mcous
commented
Feb 17, 2024
Giving this one last smoke test in a real-life suite, will update here with results
Passed our ~1000 test suite without any unexpected failures (still on Svelte v4). Had exactly one failure: a test that was using rerender and relying on the old synchronous destroy and remount behavior. Fixing this test, in turn, uncovered an issue with the type definitions for rerender - in reality, it accepts Partial<Props>, not Props.
Switching the the new await rerender(...) fixed the test, and I just pushed the type definitions fix, so I think we're all good here if CI agrees with me
yanick
commented
Feb 28, 2024
mcous
commented
Mar 16, 2024
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.
Should I just remove this now? It's a weird little bit of logic that makes it so one can call either component.$destroy or unmount in a test. It feels reasonable to only provide one way - unmount - to do this
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.
I'd tend to say "nah". It's been the established behavior, and with Svelte 4 probably being eclipsed by Svelte 5 soon, there is little gain to change the behavior now.
mcous
commented
Mar 17, 2024
@yanick heads up, looks like semantic release missed this:
[2:54:51 PM] [semantic-release] [@semantic-release/commit-analyzer] › i Analyzing commit: fix!: align `target` and `baseElement` options with testing-library (#325)
Fixes #312, fixes #313
BREAKING CHANGES: The `container` option has been renamed to `baseElement`,
`result.container` is now set to `target` rather than `baseElement`,
and `render` will now throw if you mix props with the `target` option.
[2:54:51 PM] [semantic-release] [@semantic-release/commit-analyzer] › i The commit should not trigger a release
Suspected causes:
- semantic release does not recognize the
!as a breaking change infix!: ..., so it didn't seefixnor that it was a major bump - I accidentally wrote
BREAKING CHANGES:instead ofBREAKING CHANGE:in the footer, so it also missed the major bump here
Not sure the best way to fix this up, the quickest / easiest might be a little distasteful history rewrite on next
Uh oh!
There was an error while loading. Please reload this page.
Fixes #312, fixes #313
BREAKING CHANGES: The
containeroption has been renamed tobaseElement,result.containeris now set totargetrather thanbaseElement,and
renderwill now throw if you mix props with thetargetoption.Change log
renderOptions.containertorenderOptions.baseElementbaseElementasresult.baseElementbaseElementtocomponentOptions.targetif used, elsedocument.bodycomponentOptions.targetasresult.container, which is one layer lower in the DOM than the previous behavior and matches othertesting-libraryframeworkscomponentOptions.targetwill now trigger an error if it is mixed with props, matching the behavior of other component options