Skip to content
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

Replace deprecated ReactDOM methods in tests #7167

Open
ggdouglas opened this issue Jan 14, 2025 · 1 comment
Open

Replace deprecated ReactDOM methods in tests #7167

ggdouglas opened this issue Jan 14, 2025 · 1 comment

Comments

@ggdouglas
Copy link
Contributor

Tracking work required for full compatibility with React 18. There are several tests in our test suite that reference deprecated ReactDOM.render, ReactDOM.unmountComponentAtNode and ReactDOM.findDOMNode methods. These tests should be replaced with newer infrastructure (preferably with RTL)

ReactDOM.unmountComponentAtNode(containerElement!);

ReactDOM.unmountComponentAtNode(containerElement!);

ReactDOM.unmountComponentAtNode(testsContainerElement);

ReactDOM.unmountComponentAtNode(toasterRenderRoot);

ReactDOM.unmountComponentAtNode(testsContainerElement);

ReactDOM.unmountComponentAtNode(testsContainerElement);

ReactDOM.unmountComponentAtNode(containerElement);

ReactDOM.unmountComponentAtNode(testsContainerElement);

ReactDOM.unmountComponentAtNode(containerElement);

return ReactDOM.render<React.HTMLProps<HTMLDivElement>>(

public mount(component: React.ReactElement<any>) {
// wrap in a root provider to avoid console warnings
ReactDOM.render(React.createElement(BlueprintProvider, { children: component }), this.container);
return new ElementHarness(this.container);
}

public unmount() {
ReactDOM.unmountComponentAtNode(this.container);
}

The ReactHarness code is used across several tests. This custom test harness should be replaced with RTL.

ReactDOM.unmountComponentAtNode(containerElement);

ReactDOM.unmountComponentAtNode(container);

const component = ReactDOM.render<any>(element, containerElement);

ReactDOM.unmountComponentAtNode(containerElement);

const tableBodyNode = ReactDOM.findDOMNode(tableNode.querySelector(tableBodySelector));

@ggdouglas
Copy link
Contributor Author

For the initial internal React 18 upgrade, these deprecations will need to be ignored to pass the linter: #7162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant