Skip to content

Commit 7d3a580

Browse files
committed
Deprecate ReactTestUtils.* except Simulate for now
1 parent a100af4 commit 7d3a580

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

library/facadeTest/src/main/scala/japgolly/scalajs/react/test/facade/ReactTestUtils.scala

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ trait ReactTestUtils extends js.Object {
2828
*
2929
* This helps make your tests run closer to what real users would experience when using your application.
3030
*/
31-
@deprecated("Use React.act", "3.0.0")
31+
@deprecated("Use React.act", "3.0.0 / React v18")
3232
final def act(body: js.Function0[Any]): js.Thenable[Unit] = js.native
3333

3434
/** When writing UI tests, tasks like rendering, user events, or data fetching can be considered as "units" of
@@ -45,69 +45,83 @@ trait ReactTestUtils extends js.Object {
4545
* This helps make your tests run closer to what real users would experience when using your application.
4646
*/
4747
@JSName("act")
48-
@deprecated("Use React.actAsync", "3.0.0")
48+
@deprecated("Use React.actAsync", "3.0.0 / React v18")
4949
final def actAsync(body: js.Function0[js.Thenable[Any]]): js.Thenable[Unit] = js.native
5050

5151
/** Render a component into a detached DOM node in the document. This function requires a DOM. */
52+
@deprecated("Deprecated in favour of https://testing-library.com/react", "3.0.0 / React v18")
5253
final def renderIntoDocument(element: React.Element): React.ComponentUntyped | Null = js.native
5354

5455
/**
5556
* Pass a mocked component module to this method to augment it with useful methods that allow it to be used as a dummy
5657
* React component. Instead of rendering as usual, the component will become a simple <div> (or other tag if
5758
* mockTagName is provided) containing any provided children.
5859
*/
60+
@deprecated("Deprecated in favour of https://testing-library.com/react", "3.0.0 / React v18")
5961
final def mockComponent[P <: js.Object, S <: js.Object](c: React.ComponentClass[P, S], mockTagName: String = js.native): React.ComponentClass[P, S] = js.native
6062

63+
@deprecated("Deprecated in favour of https://testing-library.com/react", "3.0.0 / React v18")
6164
final type Mounted = React.ComponentUntyped
6265

6366
/** Returns true if instance is an instance of a React componentClass. */
67+
@deprecated("Deprecated in favour of https://testing-library.com/react", "3.0.0 / React v18")
6468
final def isComponentOfType(instance: React.Element, c: React.ComponentClassUntyped): Boolean = js.native
6569

6670
/** Returns true if instance is a DOM component (such as a &lt;div&gt; or &lt;span&gt;). */
71+
@deprecated("Deprecated in favour of https://testing-library.com/react", "3.0.0 / React v18")
6772
final def isDOMComponent(instance: React.Element): Boolean = js.native
6873

6974
/** Returns true if instance is a composite component (created with React.createClass()) */
75+
@deprecated("Deprecated in favour of https://testing-library.com/react", "3.0.0 / React v18")
7076
final def isCompositeComponent(instance: React.Element): Boolean = js.native
7177

7278
/** The combination of [[isComponentOfType()]] and [[isCompositeComponent()]]. */
79+
@deprecated("Deprecated in favour of https://testing-library.com/react", "3.0.0 / React v18")
7380
final def isCompositeComponentWithType(instance: React.Element, c: React.ComponentClassUntyped): Boolean = js.native
7481

7582
/**
7683
* Traverse all components in tree and accumulate all components where test(component) is true.
7784
* This is not that useful on its own, but it's used as a primitive for other test utils.
7885
*/
86+
@deprecated("Deprecated in favour of https://testing-library.com/react", "3.0.0 / React v18")
7987
final def findAllInRenderedTree(tree: Mounted, test: js.Function1[Mounted, Boolean]): js.Array[Mounted] = js.native
8088

8189
/**
8290
* Finds all instance of components in the rendered tree that are DOM components with the class name
8391
* matching className.
8492
*/
93+
@deprecated("Deprecated in favour of https://testing-library.com/react", "3.0.0 / React v18")
8594
final def scryRenderedDOMComponentsWithClass(tree: Mounted, className: String): js.Array[Mounted] = js.native
8695

8796
/**
8897
* Like [[scryRenderedDOMComponentsWithClass()]] but expects there to be one result, and returns that one result, or
8998
* throws exception if there is any other number of matches besides one.
9099
*/
100+
@deprecated("Deprecated in favour of https://testing-library.com/react", "3.0.0 / React v18")
91101
final def findRenderedDOMComponentWithClass(tree: Mounted, className: String): Mounted = js.native
92102

93103
/**
94104
* Finds all instance of components in the rendered tree that are DOM components with the tag name
95105
* matching tagName.
96106
*/
107+
@deprecated("Deprecated in favour of https://testing-library.com/react", "3.0.0 / React v18")
97108
final def scryRenderedDOMComponentsWithTag(tree: Mounted, tagName: String): js.Array[Mounted] = js.native
98109

99110
/**
100111
* Like [[scryRenderedDOMComponentsWithTag()]] but expects there to be one result, and returns that one result, or
101112
* throws exception if there is any other number of matches besides one.
102113
*/
114+
@deprecated("Deprecated in favour of https://testing-library.com/react", "3.0.0 / React v18")
103115
final def findRenderedDOMComponentWithTag(tree: Mounted, tagName: String): Mounted = js.native
104116

105117
/** Finds all instances of components with type equal to componentClass. */
118+
@deprecated("Deprecated in favour of https://testing-library.com/react", "3.0.0 / React v18")
106119
final def scryRenderedComponentsWithType(tree: Mounted, c: React.ComponentClassUntyped): js.Array[Mounted] = js.native
107120

108121
/**
109122
* Same as [[scryRenderedComponentsWithType()]] but expects there to be one result and returns that one result, or throws
110123
* exception if there is any other number of matches besides one.
111124
*/
125+
@deprecated("Deprecated in favour of https://testing-library.com/react", "3.0.0 / React v18")
112126
final def findRenderedComponentWithType(tree: Mounted, c: React.ComponentClassUntyped): Mounted = js.native
113127
}

library/testUtil/src/main/scala/japgolly/scalajs/react/test/ReactTestUtils.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ trait ReactTestUtils extends japgolly.scalajs.react.test.internal.ReactTestUtilE
3434
private val reactRaw = japgolly.scalajs.react.facade.React
3535

3636
type Unmounted = GenericComponent.Unmounted[_, Unit]
37-
3837
type CompType = GenericComponent.ComponentRaw {type Raw <: japgolly.scalajs.react.facade.React.ComponentClassUntyped }
3938

4039
// ===================================================================================================================

0 commit comments

Comments
 (0)