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

[flags] remove enableOwnerStacks #32426

Merged
merged 2 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
167 changes: 2 additions & 165 deletions packages/internal-test-utils/__tests__/ReactInternalTestUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -857,17 +857,6 @@ describe('ReactInternalTestUtils console assertions', () => {

You must call one of the assertConsoleDev helpers between each act call."
`);
} else if (gate(flags => flags.enableOwnerStacks)) {
expect(message).toMatchInlineSnapshot(`
"asserConsoleLogsCleared(expected)

console.log was called without assertConsoleLogDev:
+ Not asserted
+ Not asserted
+ Not asserted

You must call one of the assertConsoleDev helpers between each act call."
`);
} else {
expect(message).toMatchInlineSnapshot(`
"asserConsoleLogsCleared(expected)
Expand Down Expand Up @@ -937,20 +926,6 @@ describe('ReactInternalTestUtils console assertions', () => {
+ B
+ C

You must call one of the assertConsoleDev helpers between each act call."
`);
} else if (gate(flags => flags.enableOwnerStacks)) {
expect(message).toMatchInlineSnapshot(`
"asserConsoleLogsCleared(expected)

console.warn was called without assertConsoleWarnDev:
+ A%s,
+ in App (at **)
+ B%s,
+ in App (at **)
+ C%s,
+ in App (at **)

You must call one of the assertConsoleDev helpers between each act call."
`);
} else {
Expand All @@ -959,16 +934,10 @@ describe('ReactInternalTestUtils console assertions', () => {

console.warn was called without assertConsoleWarnDev:
+ A%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)
+ B%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)
+ C%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)

You must call one of the assertConsoleDev helpers between each act call."
Expand Down Expand Up @@ -1023,33 +992,6 @@ describe('ReactInternalTestUtils console assertions', () => {
+ B
+ C

You must call one of the assertConsoleDev helpers between each act call."
`);
} else if (gate(flags => flags.enableOwnerStacks)) {
expect(message).toMatchInlineSnapshot(`
"asserConsoleLogsCleared(expected)

console.log was called without assertConsoleLogDev:
+ A
+ B
+ C

console.warn was called without assertConsoleWarnDev:
+ A%s,
+ in App (at **)
+ B%s,
+ in App (at **)
+ C%s,
+ in App (at **)

console.error was called without assertConsoleErrorDev:
+ A%s,
+ in App (at **)
+ B%s,
+ in App (at **)
+ C%s,
+ in App (at **)

You must call one of the assertConsoleDev helpers between each act call."
`);
} else {
Expand All @@ -1063,30 +1005,18 @@ describe('ReactInternalTestUtils console assertions', () => {

console.warn was called without assertConsoleWarnDev:
+ A%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)
+ B%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)
+ C%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)

console.error was called without assertConsoleErrorDev:
+ A%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)
+ B%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)
+ C%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)

You must call one of the assertConsoleDev helpers between each act call."
Expand Down Expand Up @@ -1927,20 +1857,6 @@ describe('ReactInternalTestUtils console assertions', () => {
+ Not asserted
+ Not asserted

You must call one of the assertConsoleDev helpers between each act call."
`);
} else if (gate(flags => flags.enableOwnerStacks)) {
expect(message).toMatchInlineSnapshot(`
"asserConsoleLogsCleared(expected)

console.warn was called without assertConsoleWarnDev:
+ Not asserted%s,
+ in Yield (at **)
+ Not asserted%s,
+ in Yield (at **)
+ Not asserted%s,
+ in Yield (at **)

You must call one of the assertConsoleDev helpers between each act call."
`);
} else {
Expand All @@ -1950,13 +1866,10 @@ describe('ReactInternalTestUtils console assertions', () => {
console.warn was called without assertConsoleWarnDev:
+ Not asserted%s,
+ in Yield (at **)
+ in div (at **)
+ Not asserted%s,
+ in Yield (at **)
+ in div (at **)
+ Not asserted%s,
+ in Yield (at **)
+ in div (at **)

You must call one of the assertConsoleDev helpers between each act call."
`);
Expand Down Expand Up @@ -2020,7 +1933,7 @@ describe('ReactInternalTestUtils console assertions', () => {

You must call one of the assertConsoleDev helpers between each act call."
`);
} else if (gate(flags => flags.enableOwnerStacks)) {
} else {
expect(message).toMatchInlineSnapshot(`
"asserConsoleLogsCleared(expected)

Expand All @@ -2034,26 +1947,6 @@ describe('ReactInternalTestUtils console assertions', () => {

You must call one of the assertConsoleDev helpers between each act call."
`);
} else {
expect(message).toMatchInlineSnapshot(`
"asserConsoleLogsCleared(expected)

console.error was called without assertConsoleErrorDev:
+ A%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)
+ B%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)
+ C%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)

You must call one of the assertConsoleDev helpers between each act call."
`);
}
});

Expand Down Expand Up @@ -2106,7 +1999,7 @@ describe('ReactInternalTestUtils console assertions', () => {

You must call one of the assertConsoleDev helpers between each act call."
`);
} else if (gate(flags => flags.enableOwnerStacks)) {
} else {
expect(message).toMatchInlineSnapshot(`
"asserConsoleLogsCleared(expected)

Expand All @@ -2133,45 +2026,6 @@ describe('ReactInternalTestUtils console assertions', () => {

You must call one of the assertConsoleDev helpers between each act call."
`);
} else {
expect(message).toMatchInlineSnapshot(`
"asserConsoleLogsCleared(expected)

console.log was called without assertConsoleLogDev:
+ A
+ B
+ C

console.warn was called without assertConsoleWarnDev:
+ A%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)
+ B%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)
+ C%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)

console.error was called without assertConsoleErrorDev:
+ A%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)
+ B%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)
+ C%s,
+ in Yield (at **)
+ in div (at **)
+ in App (at **)

You must call one of the assertConsoleDev helpers between each act call."
`);
}
});

Expand Down Expand Up @@ -3052,20 +2906,6 @@ describe('ReactInternalTestUtils console assertions', () => {
+ Not asserted
+ Not asserted

You must call one of the assertConsoleDev helpers between each act call."
`);
} else if (gate(flags => flags.enableOwnerStacks)) {
expect(message).toMatchInlineSnapshot(`
"asserConsoleLogsCleared(expected)

console.error was called without assertConsoleErrorDev:
+ Not asserted%s,
+ in Yield (at **)
+ Not asserted%s,
+ in Yield (at **)
+ Not asserted%s,
+ in Yield (at **)

You must call one of the assertConsoleDev helpers between each act call."
`);
} else {
Expand All @@ -3075,13 +2915,10 @@ describe('ReactInternalTestUtils console assertions', () => {
console.error was called without assertConsoleErrorDev:
+ Not asserted%s,
+ in Yield (at **)
+ in div (at **)
+ Not asserted%s,
+ in Yield (at **)
+ in div (at **)
+ Not asserted%s,
+ in Yield (at **)
+ in div (at **)

You must call one of the assertConsoleDev helpers between each act call."
`);
Expand Down
18 changes: 5 additions & 13 deletions packages/internal-test-utils/consoleMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

/* eslint-disable react-internal/no-production-logging */

const chalk = require('chalk');
const util = require('util');
const shouldIgnoreConsoleError = require('./shouldIgnoreConsoleError');
Expand Down Expand Up @@ -38,25 +39,16 @@ const patchConsoleMethod = (methodName, logged) => {
(methodName === 'error' || methodName === 'warn')
) {
const React = require('react');

// Ideally we could remove this check, but we have some tests like
// useSyncExternalStoreShared-test that tests against React 17,
// which doesn't have the captureOwnerStack method.
if (React.captureOwnerStack) {
// enableOwnerStacks enabled. When it's always on, we can assume this case.
const stack = React.captureOwnerStack();
if (stack) {
format += '%s';
args.push(stack);
}
} else {
// Otherwise we have to use internals to emulate parent stacks.
const ReactSharedInternals =
React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ||
React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
if (ReactSharedInternals && ReactSharedInternals.getCurrentStack) {
const stack = ReactSharedInternals.getCurrentStack();
if (stack !== '') {
format += '%s';
args.push(stack);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,7 @@ describe('ReactCache', () => {
"boolean, but instead received: [ 'Hi', 100 ]\n\n" +
'To use non-primitive values as keys, you must pass a hash ' +
'function as the second argument to createResource().\n' +
' in App (at **)' +
(gate(flags => flags.enableOwnerStacks)
? ''
: '\n in Suspense (at **)'),

' in App (at **)',
...(gate('enableSiblingPrerendering')
? [
'Invalid key type. Expected a string, number, symbol, or ' +
Expand Down
Loading
Loading