Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c35e37a
mark react-events as private so we publish script skips it for now
Apr 3, 2019
dc605c1
Merge remote-tracking branch 'upstream/master'
Apr 3, 2019
a09bd0f
Merge remote-tracking branch 'upstream/master'
Apr 3, 2019
48ffcee
Merge remote-tracking branch 'upstream/master'
Apr 12, 2019
f0c3493
warn when using the wrong act() around create/updates
Apr 12, 2019
c1e2986
Merge remote-tracking branch 'upstream/master' into renderer-specific…
Apr 12, 2019
bd31fed
make a proper fixture for act()
Apr 14, 2019
b417644
cleanup fixtures/dom/.gitignore
Apr 14, 2019
6812f6e
verify that it 'works' with art+dom
Apr 14, 2019
190f656
verify that it 'works' with art+test
Apr 14, 2019
7caa1b2
augh prettier
Apr 14, 2019
4fc4c39
tweak warning messages
Apr 15, 2019
91c5d79
Stop tracking bundle sizes (#15404)
acdlite Apr 12, 2019
46a4237
React events: ignore device buttons that aren't for primary interacti…
necolas Apr 12, 2019
e4d93a7
warn when using the wrong act() around create/updates
Apr 12, 2019
da0e642
Merge branch 'renderer-specific-act-warning' of github.com:threepoint…
Apr 15, 2019
d008007
Merge remote-tracking branch 'upstream/master' into renderer-specific…
Apr 15, 2019
0aebde1
lose ReactActingUpdatesSigil.js, use flushPassiveEffects as the actin…
Apr 15, 2019
7f3fd8f
copy nit
Apr 15, 2019
b0391d7
Update ReactShouldWarnActingUpdates.js
Apr 16, 2019
29e2cc7
rename ReactShouldWarnActingUpdates to ReactActingRendererSigi, merge…
Apr 18, 2019
cd695e6
augh prettier
Apr 18, 2019
d00d827
move the check to updatecontainer, run the act fixtures in ci
Apr 23, 2019
82124cc
s/console.error/spy
Apr 23, 2019
c2a52f5
run yarn before dom-fixture tests
Apr 23, 2019
381d292
Merge branch 'master' into renderer-specific-act-warning
threepointone May 17, 2019
275d47c
Merge branch 'master' into renderer-specific-act-warning
threepointone May 17, 2019
26ce8b4
Merge branch 'master' into renderer-specific-act-warning
threepointone May 21, 2019
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
2 changes: 1 addition & 1 deletion fixtures/act/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ beforeEach(() => {
function confirmWarning() {
expect(spy).toHaveBeenCalledWith(
expect.stringContaining(
"It looks like you're using the wrong act() around your interactions."
"It looks like you're using the wrong act() around your test interactions."
),
''
);
Expand Down
8 changes: 4 additions & 4 deletions packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ describe('ReactTestUtils.act()', () => {
it('warns if you return a value inside act', () => {
expect(() => act(() => null)).toWarnDev(
[
'The callback passed to act(...) function must return undefined, or a Promise.',
'The callback passed to act(...) function must return undefined or a Promise.',
],
{withoutStack: true},
);
expect(() => act(() => 123)).toWarnDev(
[
'The callback passed to act(...) function must return undefined, or a Promise.',
'The callback passed to act(...) function must return undefined or a Promise.',
],
{withoutStack: true},
);
Expand All @@ -240,7 +240,7 @@ describe('ReactTestUtils.act()', () => {
it('warns if you try to await an .act call', () => {
expect(() => act(() => {}).then(() => {})).toWarnDev(
[
'Do not await the result of calling act(...) with sync logic, it is not a Promise.',
'Do not await the result of calling a synchronous act(...), it is not a Promise.',
],
{withoutStack: true},
);
Expand Down Expand Up @@ -306,7 +306,7 @@ describe('ReactTestUtils.act()', () => {
if (__DEV__) {
expect(console.error.calls.count()).toEqual(1);
expect(console.error.calls.argsFor(0)[0]).toMatch(
'You called act(async () => ...) without await.',
'You called act(async () => ...) without awaiting its result.',
);
}
});
Expand Down
11 changes: 7 additions & 4 deletions packages/react-dom/src/test-utils/ReactTestUtilsAct.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ function act(callback: () => Thenable) {
if (called === false) {
warningWithoutStack(
null,
'You called act(async () => ...) without await. ' +
'You called act(async () => ...) without awaiting its result. ' +
'This could lead to unexpected testing behaviour, interleaving multiple act ' +
'calls and mixing their scopes. You should - await act(async () => ...);',
'calls and mixing their scopes. You should await asynchronous act() ' +
'calls, like so -\n' +
'await act(async () => ...);\n',
);
}
});
Expand Down Expand Up @@ -141,7 +143,7 @@ function act(callback: () => Thenable) {
warningWithoutStack(
result === undefined,
'The callback passed to act(...) function ' +
'must return undefined, or a Promise. You returned %s',
'must return undefined or a Promise. You returned %s',
result,
);
}
Expand All @@ -161,7 +163,8 @@ function act(callback: () => Thenable) {
if (__DEV__) {
warningWithoutStack(
false,
'Do not await the result of calling act(...) with sync logic, it is not a Promise.',
'Do not await the result of calling a synchronous act(...), it is not a Promise. \n' +
'Remove the `await` statement before this act() call.',
);
}
resolve();
Expand Down
11 changes: 7 additions & 4 deletions packages/react-noop-renderer/src/createReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,11 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
if (called === false) {
warningWithoutStack(
null,
'You called act(async () => ...) without await. ' +
'You called act(async () => ...) without awaiting its result. ' +
'This could lead to unexpected testing behaviour, interleaving multiple act ' +
'calls and mixing their scopes. You should - await act(async () => ...);',
'calls and mixing their scopes. You should await asynchronous act() ' +
'calls, like so -\n' +
'await act(async () => ...);\n',
);
}
});
Expand Down Expand Up @@ -754,7 +756,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
warningWithoutStack(
result === undefined,
'The callback passed to act(...) function ' +
'must return undefined, or a Promise. You returned %s',
'must return undefined or a Promise. You returned %s',
result,
);
}
Expand All @@ -774,7 +776,8 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
if (__DEV__) {
warningWithoutStack(
false,
'Do not await the result of calling act(...) with sync logic, it is not a Promise.',
'Do not await the result of calling a synchronous act(...), it is not a Promise. \n' +
'Remove the `await` statement before this act() call.',
);
}
resolve();
Expand Down
22 changes: 14 additions & 8 deletions packages/react-reconciler/src/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2087,10 +2087,17 @@ export function warnIfNotScopedWithMatchingAct(fiber: Fiber): void {
// it looks like we're using the wrong matching act(), so log a warning
warningWithoutStack(
false,
"It looks like you're using the wrong act() around your interactions.\n" +
'Be sure to use the matching version of act() corresponding to your renderer. e.g. -\n' +
"for react-dom, import {act} from 'react-test-utils';\n" +
'for react-test-renderer, const {act} = TestRenderer.' +
"It looks like you're using the wrong act() around your test interactions.\n" +
'Be sure to use the matching version of act() corresponding to your renderer. e.g. -\n\n' +
'// for react-dom:\n' +
"import {act} from 'react-test-utils';\n" +
'//...\n' +
'act(() => ...);\n\n' +
'// for react-test-renderer:\n' +
"import TestRenderer from 'react-test-renderer';\n" +
'const {act} = TestRenderer;\n' +
'//...\n' +
'act(() => ...);' +
'%s',
getStackByFiberInDevAndProd(fiber),
);
Expand All @@ -2115,13 +2122,12 @@ function warnIfNotCurrentlyActingUpdatesInDEV(fiber: Fiber): void {
false,
'An update to %s inside a test was not wrapped in act(...).\n\n' +
'When testing, code that causes React state updates should be ' +
'wrapped into act(...):\n\n' +
'act(() => {\n' +
'wrapped inside act(...):\n\n' +
'await act(async () => {\n' +
' /* fire events that update state */\n' +
'});\n' +
'/* assert on the output */\n\n' +
"This ensures that you're testing the behavior the user would see " +
'in the browser.' +
"This ensures that you're testing behavior similar to what a user would experience.\n" +
' Learn more at https://fb.me/react-wrap-tests-with-act' +
'%s',
getComponentName(fiber.type),
Expand Down
11 changes: 7 additions & 4 deletions packages/react-test-renderer/src/ReactTestRendererAct.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ function act(callback: () => Thenable) {
if (called === false) {
warningWithoutStack(
null,
'You called act(async () => ...) without await. ' +
'You called act(async () => ...) without awaiting its result. ' +
'This could lead to unexpected testing behaviour, interleaving multiple act ' +
'calls and mixing their scopes. You should - await act(async () => ...);',
'calls and mixing their scopes. You should await asynchronous act() ' +
'calls, like so -\n' +
'await act(async () => ...);\n',
);
}
});
Expand Down Expand Up @@ -122,7 +124,7 @@ function act(callback: () => Thenable) {
warningWithoutStack(
result === undefined,
'The callback passed to act(...) function ' +
'must return undefined, or a Promise. You returned %s',
'must return undefined or a Promise. You returned %s',
result,
);
}
Expand All @@ -142,7 +144,8 @@ function act(callback: () => Thenable) {
if (__DEV__) {
warningWithoutStack(
false,
'Do not await the result of calling act(...) with sync logic, it is not a Promise.',
'Do not await the result of calling a synchronous act(...), it is not a Promise. \n' +
'Remove the `await` statement before this act() call.',
);
}
resolve();
Expand Down