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

Conversation

sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Dec 13, 2024

Description

close #485

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Copy link

pkg-pr-new bot commented Dec 13, 2024

Open in Stackblitz

npm i https://pkg.pr.new/@vitejs/plugin-vue@486
npm i https://pkg.pr.new/@vitejs/plugin-vue-jsx@486

commit: 3f55553

@@ -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.

@sapphi-red
Copy link
Member Author

The CI passed five times in a row. I guess this change made it stable.

@edison1105 edison1105 merged commit bebb87b into main Dec 13, 2024
10 checks passed
@edison1105 edison1105 deleted the test/fix-flaky-should-reload-test-fail branch December 13, 2024 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

playground/vue/__tests__/vue.spec.ts > hmr > should reload when relies file changed test is flaky
2 participants