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
Prev Previous commit
Next Next commit
move the check to updatecontainer, run the act fixtures in ci
  • Loading branch information
Sunil Pai committed Apr 23, 2019
commit d00d827501d1416bdd95fcf5ad88047aa51d30eb
26 changes: 23 additions & 3 deletions fixtures/dom/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import TestRenderer from 'react-test-renderer';

let spy;
beforeEach(() => {
spy = jest.spyOn(global.console, 'error');
spy = jest.spyOn(console, 'error').mockImplementation(() => {});
});

function confirmWarning() {
expect(spy).toHaveBeenCalledWith(
expect(console.error).toHaveBeenCalledWith(
expect.stringContaining(
"It looks like you're using the wrong act() around your test interactions."
),
Expand All @@ -35,6 +35,14 @@ it("doesn't warn when you use the right act + renderer: test", () => {
expect(spy).not.toHaveBeenCalled();
});

it('works with createRoot().render combo', () => {
const root = ReactDOM.unstable_createRoot(document.createElement('div'));
TestRenderer.act(() => {
root.render(<App />);
});
confirmWarning();
});

it('warns when using the wrong act version - test + dom: render', () => {
TestRenderer.act(() => {
TestUtils.renderIntoDocument(<App />);
Expand All @@ -56,13 +64,25 @@ it('warns when using the wrong act version - test + dom: updates', () => {
confirmWarning();
});

it('warns when using the wrong act version - dom + test: render', () => {
it('warns when using the wrong act version - dom + test: .create()', () => {
TestUtils.act(() => {
TestRenderer.create(<App />);
});
confirmWarning();
});

it('warns when using the wrong act version - dom + test: .update()', () => {
let root;
// use the right one here so we don't get the first warning
TestRenderer.act(() => {
root = TestRenderer.create(<App key="one" />);
});
TestUtils.act(() => {
root.update(<App key="two" />);
});
confirmWarning();
});

it('warns when using the wrong act version - dom + test: updates', () => {
let setCtr;
function Counter(props) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"test-prod-build": "yarn test-build-prod",
"test-build": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.build.js",
"test-build-prod": "cross-env NODE_ENV=production jest --config ./scripts/jest/config.build.js",
"test-dom-fixture": "cd fixtures/dom && yarn prestart && yarn test",
"flow": "node ./scripts/tasks/flow.js",
"flow-ci": "node ./scripts/tasks/flow-ci.js",
"prettier": "node ./scripts/prettier/index.js write-changed",
Expand Down
19 changes: 9 additions & 10 deletions packages/react-reconciler/src/ReactFiberReconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,7 @@ export function createContainer(
isConcurrent: boolean,
hydrate: boolean,
): OpaqueRoot {
const fiberRoot = createFiberRoot(containerInfo, isConcurrent, hydrate);
if (__DEV__) {
// jest isn't a 'global', it's just exposed to tests via a wrapped function
// further, this isn't a test file, so flow doesn't recognize the symbol. So...
// $FlowExpectedError - because requirements don't give a damn about your type sigs.
if ('undefined' !== typeof jest) {
warnIfNotScopedWithMatchingAct(fiberRoot.current);
}
}
return fiberRoot;
return createFiberRoot(containerInfo, isConcurrent, hydrate);
}

export function updateContainer(
Expand All @@ -298,6 +289,14 @@ export function updateContainer(
const current = container.current;
const currentTime = requestCurrentTime();
const expirationTime = computeExpirationForFiber(currentTime, current);
if (__DEV__) {
// jest isn't a 'global', it's just exposed to tests via a wrapped function
// further, this isn't a test file, so flow doesn't recognize the symbol. So...
// $FlowExpectedError - because requirements don't give a damn about your type sigs.
if ('undefined' !== typeof jest) {
warnIfNotScopedWithMatchingAct(current);
}
}
return updateContainerAtExpirationTime(
element,
container,
Expand Down
1 change: 1 addition & 0 deletions scripts/circleci/test_entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ if [ $((2 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
COMMANDS_TO_RUN+=('./scripts/circleci/build.sh')
COMMANDS_TO_RUN+=('yarn test-build --maxWorkers=2')
COMMANDS_TO_RUN+=('yarn test-build-prod --maxWorkers=2')
COMMANDS_TO_RUN+=('yarn test-dom-fixture')
COMMANDS_TO_RUN+=('cp ./scripts/rollup/results.json ./build/bundle-sizes.json')
COMMANDS_TO_RUN+=('node ./scripts/tasks/danger')
COMMANDS_TO_RUN+=('./scripts/circleci/upload_build.sh')
Expand Down