diff --git a/src/__tests__/profiling-test.js b/src/__tests__/profiling-test.js
index 5bd2e037bb..6c49272847 100644
--- a/src/__tests__/profiling-test.js
+++ b/src/__tests__/profiling-test.js
@@ -50,11 +50,14 @@ describe('profiling', () => {
utils.act(() => ReactDOM.render(, container));
utils.act(() => store.stopProfiling());
+ let suspenseResolved = false;
+
function Suspender({ rendererID, rootID }) {
const profilingSummary = store.profilingCache.ProfilingSummary.read({
rendererID,
rootID,
});
+ suspenseResolved = true;
expect(profilingSummary).toMatchSnapshot('ProfilingSummary');
return null;
}
@@ -70,6 +73,8 @@ describe('profiling', () => {
)
);
+ expect(suspenseResolved).toBe(true);
+
done();
});
});
@@ -96,12 +101,15 @@ describe('profiling', () => {
utils.act(() => ReactDOM.render(, container));
utils.act(() => store.stopProfiling());
+ let suspenseResolved = false;
+
function Suspender({ commitIndex, rendererID, rootID }) {
const commitDetails = store.profilingCache.CommitDetails.read({
commitIndex,
rendererID,
rootID,
});
+ suspenseResolved = true;
expect(commitDetails).toMatchSnapshot(
`CommitDetails commitIndex: ${commitIndex}`
);
@@ -112,7 +120,8 @@ describe('profiling', () => {
const rootID = store.roots[0];
for (let commitIndex = 0; commitIndex <= 3; commitIndex++) {
- await utils.actSuspense(() =>
+ suspenseResolved = false;
+ await utils.actSuspense(() => {
TestRenderer.create(
{
rootID={rootID}
/>
- )
- );
+ );
+ });
+ expect(suspenseResolved).toBe(true);
}
done();
@@ -150,12 +160,15 @@ describe('profiling', () => {
utils.act(() => ReactDOM.render(, container));
utils.act(() => store.stopProfiling());
+ let suspenseResolved = false;
+
function Suspender({ fiberID, rendererID, rootID }) {
const fiberCommits = store.profilingCache.FiberCommits.read({
fiberID,
rendererID,
rootID,
});
+ suspenseResolved = true;
expect(fiberCommits).toMatchSnapshot(
`FiberCommits: element ${fiberID}`
);
@@ -166,6 +179,7 @@ describe('profiling', () => {
const rootID = store.roots[0];
for (let index = 0; index < store.numElements; index++) {
+ suspenseResolved = false;
await utils.actSuspense(() => {
const fiberID = store.getElementIDAtIndex(index);
if (fiberID == null) {
@@ -181,6 +195,7 @@ describe('profiling', () => {
);
});
+ expect(suspenseResolved).toBe(true);
}
done();
@@ -219,11 +234,14 @@ describe('profiling', () => {
);
utils.act(() => store.stopProfiling());
+ let suspenseResolved = false;
+
function Suspender({ rendererID, rootID }) {
const interactions = store.profilingCache.Interactions.read({
rendererID,
rootID,
});
+ suspenseResolved = true;
expect(interactions).toMatchSnapshot('Interactions');
return null;
}
@@ -239,6 +257,8 @@ describe('profiling', () => {
)
);
+ expect(suspenseResolved).toBe(true);
+
done();
});
});
diff --git a/src/devtools/store.js b/src/devtools/store.js
index d6e93d9fb9..7a84b33647 100644
--- a/src/devtools/store.js
+++ b/src/devtools/store.js
@@ -852,6 +852,10 @@ export default class Store extends EventEmitter {
weight: 0,
});
+ if (this._isProfiling) {
+ this._profilingSnapshotsByRootID.set(id, new Map());
+ }
+
haveRootsChanged = true;
} else {
parentID = ((operations[i]: any): number);