release alpha as stable #11
Merged
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.
BREAKING CHANGE: This release has to break some old APIs to stay compatible with React 19.
renderis nowasyncand should beawaitedThis is the core change - due to the impementation of sibling prerendering on the React side, rendering has become more
asyncand tests that interacted withrenderin a synchronous fashion would end up with not-resolving suspense boundaries.Please adjust your tests accordingly:
const {takeRender, render} = createRenderStream({ /* ... */ }) - const utils = render(<Counter />) + const utils = await render(<Counter />)enforcing of
IS_REACT_ACT_ENVIRONMENT == falseIn combination with issues we have have seen in the past, we have deduced that the testing approach of this library only really works in a "real-world" scenario, not in an
actenvironment.As a result, we will now throw an error if you try to use it in an environment where
IS_REACT_ACT_ENVIRONMENTis truthy.We are shipping a new tool,
disableActEnvironmentto prepare your environment for the duration of a test in a safe manner.This helper can either be used with explicit resource management using the
usingkeyword:of by manually calling
cleanup:This function does not only adjust your
IS_REACT_ACT_ENVIRONMENTvalue, but it will also temporarily adjust the@testing-library/domconfiguration in a way so that e.g. calls touserEventwill not automatically be wrapped inact.Of course you can also use this tool on a per-file basis instead of a per-test basis, but keep in mind that doing so will break any React Testing Library tests that might be in the same file.
renderis now it's own implementationPreviously, we used the
renderfunction of React Testing Library, but with the new restrictions this is no longer possible and we are shipping our own implementation.As a result, some less-common options are not supported in the new implementation. If you have a need for these, please let us know!
hydratewas removedlegacyRootwas removed. If you are using React 17, it will automatically switch toReactDOM.render, otherwise we will usecreateRootCaution
React 17 does not look for
IS_REACT_ACT_ENVIRONMENTto determine if it is running in anact-environment, but rathertypeof jest !== "undefined".If you have to test React 17, we recommend to patch it with a
patch-packagepatchrenderToRenderStreamwas removedAs you now have to
awaittherendercall,renderToRenderStreamhad no real value anymore.Where previously, the second line of
could be omitted and could save you some code, now that second line would become required.
This now was not any shorter than calling
createRenderStreamandrenderStream.renderinstead, and as both of these APIs now did the same thing in a different fashion, this would lead to confusion to no more benefit, so the API was removed.