-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
Modernize tests #1108
Modernize tests #1108
Conversation
Doc update is pending. |
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.
Wow! That was a lot of work. LGTM.
@@ -1,20 +1,22 @@ | |||
package downstream | |||
// package downstream |
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.
Can this file go away?
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.
We will reinstate it once we release 3.0.0.
This PR is a step forward into removing
ReactTestUtils
in favor of the newerReactTestUtils2
(which will be renamed once the former is removed).It also removes all uses of the sync version of
act
in favor of the async one, given that the React docs specify that:A number of scaffolding code was also implemented:
AsyncTestSuite
allows running tests that return anAsyncCallback
and runs them. This is not published but rather copied and pasted whenever it's used. I'm not sure where to place it and it would probably need to be in its ownscalajs-react-utest-acb
bundle.polyfill.js
now provides access toMessageChannel
, which allows executingasync
/await
withinjsdom
. Again, this is copied in the few test project where it is used.Resource
implements a managed resource. It is a generic (and therefore async) version ofWithDsl
. I thinkWithDsl
can be replaced in the future withResource[Id]
. However, we may end up deprecating and removingWithDsl
together with the sync version ofact
. This class only lives in the testing utils project, but it may be useful for other things (likeAroundReact
). If we decide to adopt it for client use, we may want to polish it up a bit. Eg: build an AST and then interpret it, rather than usingvar
s, and making sure it is stack safe.The few places where
ReactTestUtils
is still used is where class components are tested. These tests need access to the mounted versions of the components, which the modern testing framework doesn't seem to provide. Probably the course of action here will be just to remove these tests, or move them all, together withReactTestUtils
to atests-legacy
project. I'm open to suggestions.