Skip to content

Commit ad5e486

Browse files
authored
Merge pull request #59 from hypothesis/mount-prepare-container
Add prepareContainer option to mount function
2 parents 5a14b53 + e1e6f6b commit ad5e486

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/mount.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ export type MountOptions = {
1111
* attached to `document.body`.
1212
*/
1313
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;
1421
};
1522

1623
/**
@@ -19,13 +26,17 @@ export type MountOptions = {
1926
* The component can be unmounted by calling `wrapper.unmount()` or by calling
2027
* {@link unmountAll} at the end of the test.
2128
*/
22-
export function mount(jsx: VNode, { connected = false }: MountOptions = {}) {
29+
export function mount(
30+
jsx: VNode,
31+
{ connected = false, prepareContainer }: MountOptions = {},
32+
) {
2333
let wrapper;
2434
if (connected) {
2535
const container = document.createElement('div');
2636
container.setAttribute('data-enzyme-container', '');
2737
containers.push(container);
2838

39+
prepareContainer?.(container);
2940
document.body.append(container);
3041

3142
wrapper = enzyme.mount(jsx, { attachTo: container });

0 commit comments

Comments
 (0)