Skip to content

Commit 0008621

Browse files
chore(deps): bump @changesets/get-dependents-graph from 2.1.2 to 2.1.3 (#4110)
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: ScriptedAlchemy <[email protected]>
1 parent ec20a31 commit 0008621

File tree

4 files changed

+2935
-779
lines changed

4 files changed

+2935
-779
lines changed

.changeset/friendly-lions-sleep.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/bridge-react': patch
3+
---
4+
5+
test(bridge-react): stabilize async assertions for bridge tests

packages/assemble-release-plan/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"dependencies": {
3939
"@changesets/errors": "^0.2.0",
40-
"@changesets/get-dependents-graph": "^2.1.2",
40+
"@changesets/get-dependents-graph": "^2.1.3",
4141
"@changesets/should-skip-package": "^0.1.1",
4242
"@changesets/types": "^6.0.0",
4343
"@manypkg/get-packages": "^1.1.3",

packages/bridge/bridge-react/__tests__/bridge.spec.tsx

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
screen,
88
waitFor,
99
} from '@testing-library/react';
10-
import { createContainer, getHtml, sleep } from './util';
10+
import { createContainer, getHtml } from './util';
1111

1212
describe('bridge', () => {
1313
let containerInfo: ReturnType<typeof createContainer>;
@@ -31,17 +31,28 @@ describe('bridge', () => {
3131
dom: containerInfo?.container,
3232
});
3333

34-
await sleep(200);
35-
expect(document.querySelector('#container')!.innerHTML).toContain(
36-
'<div>life cycle render</div>',
34+
await waitFor(
35+
() => {
36+
expect(document.querySelector('#container')?.innerHTML).toContain(
37+
'<div>life cycle render</div>',
38+
);
39+
},
40+
{ timeout: 2000 },
3741
);
3842

3943
lifeCycle.destroy({
4044
dom: containerInfo?.container,
4145
moduleName: 'test',
4246
});
4347

44-
expect(document.querySelector('#container')!.innerHTML).toContain('');
48+
await waitFor(
49+
() => {
50+
expect(
51+
(document.querySelector('#container')?.innerHTML || '').trim(),
52+
).toBe('');
53+
},
54+
{ timeout: 2000 },
55+
);
4556
});
4657

4758
it('createRemoteAppComponent', async () => {
@@ -66,9 +77,13 @@ describe('bridge', () => {
6677
);
6778
expect(getHtml(container)).toMatch('loading');
6879

69-
await sleep(200);
70-
expect(getHtml(container)).toMatch('life cycle render');
71-
expect(getHtml(container)).toMatch('hello world');
80+
await waitFor(
81+
() => {
82+
expect(getHtml(container)).toMatch('life cycle render');
83+
expect(getHtml(container)).toMatch('hello world');
84+
},
85+
{ timeout: 2000 },
86+
);
7287
});
7388

7489
it('createRemoteAppComponent and obtain ref property', async () => {
@@ -97,10 +112,14 @@ describe('bridge', () => {
97112
);
98113
expect(getHtml(container)).toMatch('loading');
99114

100-
await sleep(200);
101-
expect(getHtml(container)).toMatch('life cycle render');
102-
expect(getHtml(container)).toMatch('hello world');
103-
expect(ref.current).not.toBeNull();
115+
await waitFor(
116+
() => {
117+
expect(getHtml(container)).toMatch('life cycle render');
118+
expect(getHtml(container)).toMatch('hello world');
119+
expect(ref.current).not.toBeNull();
120+
},
121+
{ timeout: 2000 },
122+
);
104123
});
105124

106125
it('createRemoteAppComponent with custom createRoot prop', async () => {
@@ -131,7 +150,11 @@ describe('bridge', () => {
131150
const { container } = render(<RemoteComponent />);
132151
expect(getHtml(container)).toMatch('loading');
133152

134-
await sleep(200);
135-
expect(renderMock).toHaveBeenCalledTimes(1);
153+
await waitFor(
154+
() => {
155+
expect(renderMock).toHaveBeenCalledTimes(1);
156+
},
157+
{ timeout: 2000 },
158+
);
136159
});
137160
});

0 commit comments

Comments
 (0)