Skip to content

Commit 516308c

Browse files
authored
test: use polling for hmr tests in vite-ssr suite (#384)
1 parent 7758a56 commit 516308c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/e2e-tests/vite-ssr-esm/__tests__/vite-ssr-esm.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ if (!isBuild) {
6363
'<div id="hmr-test">foo</div>\n<!-- HMR-TEMPLATE-INJECT -->'
6464
)
6565
);
66-
expect(await getText(`#hmr-test`)).toBe('foo');
66+
await untilMatches(() => getText(`#hmr-test`), 'foo', '#hmr-test contains text foo');
6767
});
6868
test('should apply style update', async () => {
6969
expect(await getColor(`h1`)).toBe('green');
7070
await updateApp((content) => content.replace('color: green', 'color: red'));
71-
expect(await getColor(`h1`)).toBe('red');
71+
await untilMatches(() => getColor('h1'), 'red', 'h1 has color red');
7272
});
7373
test('should not preserve state of updated props', async () => {
7474
expect(await getText(`#foo`)).toBe('foo');
7575
await updateApp((content) => content.replace("foo = 'foo'", "foo = 'bar'"));
76-
expect(await getText(`#foo`)).toBe('bar');
76+
await untilMatches(() => getText(`#foo`), 'bar', '#foo contains text bar');
7777
});
7878
});
7979
}

packages/e2e-tests/vite-ssr/__tests__/vite-ssr.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ if (!isBuild) {
5959
'<div id="hmr-test">foo</div>\n<!-- HMR-TEMPLATE-INJECT -->'
6060
)
6161
);
62-
expect(await getText(`#hmr-test`)).toBe('foo');
62+
await untilMatches(() => getText(`#hmr-test`), 'foo', '#hmr-test contains text foo');
6363
});
6464
test('should apply style update', async () => {
6565
expect(await getColor(`h1`)).toBe('green');
6666
await updateApp((content) => content.replace('color: green', 'color: red'));
67-
expect(await getColor(`h1`)).toBe('red');
67+
await untilMatches(() => getColor('h1'), 'red', 'h1 has color red');
6868
});
6969
test('should not preserve state of updated props', async () => {
7070
expect(await getText(`#foo`)).toBe('foo');
7171
await updateApp((content) => content.replace("foo = 'foo'", "foo = 'bar'"));
72-
expect(await getText(`#foo`)).toBe('bar');
72+
await untilMatches(() => getText(`#foo`), 'bar', '#foo contains text bar');
7373
});
7474
});
7575
}

0 commit comments

Comments
 (0)