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

[Tests] Reset modules by default #28254

Merged
merged 4 commits into from
Feb 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix for refs-test
  • Loading branch information
rickhanlonii committed Feb 6, 2024
commit d8315a634fa08b3ab9a10c7a0c00f617baed2025
11 changes: 11 additions & 0 deletions packages/react-dom/src/__tests__/refs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,14 @@ describe('creating element with string ref in constructor', () => {
});

describe('strings refs across renderers', () => {
beforeEach(() => {
React = require('react');
ReactDOMClient = require('react-dom/client');
ReactFeatureFlags = require('shared/ReactFeatureFlags');
ReactTestUtils = require('react-dom/test-utils');
act = require('internal-test-utils').act;
});

it('does not break', async () => {
class Parent extends React.Component {
render() {
Expand All @@ -582,10 +590,13 @@ describe('strings refs across renderers', () => {

class Indirection extends React.Component {
componentDidUpdate() {
jest.resetModules();
// One ref is being rendered later using another renderer copy.
const AnotherCopyOfReactDOM = require('react-dom');
const AnotherCopyOfReactDOMClient = require('react-dom/client');
const root = AnotherCopyOfReactDOMClient.createRoot(div2);

// TODO: this should error since flushSync is called in a lifecycle.
AnotherCopyOfReactDOM.flushSync(() => {
root.render(this.props.child2);
});
Expand Down