test: fix timeout hiding runtime build error #3185
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Setup for the screenshots: I forced a runtime build error, by using
configResolved
to get the config in an internal plugin. This is ok according to the public API of vite, but internal plugins don't get this hook called (and you should directly get the config through params).In the current test output for ssr-react, the build failed but the tests continued to run and trying to use
await page.click
caused a timeout that is reported and hides the real issueThis PR closes the page if there is an exception during the test setup, resolving the await and timeout issue. The real error gets properly reported but it is duplicated, as
logLevel: 'error'
is used to do the builds for the test suite so it is reported both by Vite and by Jest.To avoid this, the logLevel is set as 'silent' so the only reported exception is logged by Jest
Note: I included both changes in the same PR because in the current test setup we don't have the duplicated log error.
Additional context
The Jest log is a lot better than the one generated internally by Vite, it would be good to see if we could get the same output when the user uses the cli.
What is the purpose of this pull request?