File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ export type MountOptions = {
11
11
* attached to `document.body`.
12
12
*/
13
13
connected ?: boolean ;
14
+
15
+ /**
16
+ * When `connected` is true, allows to customize the container to which the
17
+ * wrapper is connected to.
18
+ * Useful to add custom styles and such.
19
+ */
20
+ prepareContainer ?: ( container : HTMLElement ) => void ;
14
21
} ;
15
22
16
23
/**
@@ -19,13 +26,17 @@ export type MountOptions = {
19
26
* The component can be unmounted by calling `wrapper.unmount()` or by calling
20
27
* {@link unmountAll} at the end of the test.
21
28
*/
22
- export function mount ( jsx : VNode , { connected = false } : MountOptions = { } ) {
29
+ export function mount (
30
+ jsx : VNode ,
31
+ { connected = false , prepareContainer } : MountOptions = { } ,
32
+ ) {
23
33
let wrapper ;
24
34
if ( connected ) {
25
35
const container = document . createElement ( 'div' ) ;
26
36
container . setAttribute ( 'data-enzyme-container' , '' ) ;
27
37
containers . push ( container ) ;
28
38
39
+ prepareContainer ?.( container ) ;
29
40
document . body . append ( container ) ;
30
41
31
42
wrapper = enzyme . mount ( jsx , { attachTo : container } ) ;
You can’t perform that action at this time.
0 commit comments