Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix flaky should reload test fail #486

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion playground/vue/__tests__/vue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,11 @@ describe('hmr', () => {

test('should reload when relies file changed', async () => {
// rerender
editFile('Hmr.vue', (code) => code.replace('HMR', 'HMR updated'))
await untilUpdated(() => page.textContent('h2.hmr'), 'HMR updated')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

h2.hmr already contained HMR updated because it was updated at

editFile('Hmr.vue', (code) => code.replace('HMR', 'HMR updated'))
await untilUpdated(() => page.textContent('h2.hmr'), 'HMR updated')

So this untilUpdated asserted nothing.

That made editFile('Hmr.vue' and editFile('Hmr.vue' to run almost the same time and caused the file-changed message to be sent in reverse order sometimes.
When the file-changed message is sent in reverse order, a renderer happens and thus the test fails.

editFile('Hmr.vue', (code) =>
code.replace('HMR updated', 'HMR updated updated'),
)
await untilUpdated(() => page.textContent('h2.hmr'), 'HMR updated updated')
await untilUpdated(() => page.textContent('.hmr-number'), '100')

// reload
Expand Down
Loading