Dependency Extraction Webpack Plugin: Fix test issues#57332
Merged
Conversation
|
Size Change: 0 B Total Size: 1.71 MB ℹ️ View Unchanged
|
|
Flaky tests detected in be0babc. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7297949922
|
gziolo
approved these changes
Dec 22, 2023
gziolo
left a comment
Member
There was a problem hiding this comment.
It looks good to me. I can confirm that hash changes should change whenever the configuration changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What?
Fix test issues in the Dependency Extraction Webpack Plugin.
This also updates the test name and snapshots in preparation for #57199.
We add explicit options
target: 'web'andexperiments: {}. These do not change compilation (except for the hash), but are necessary for #57199.Why?
While working on #57199 I struggled with tests that would hang without explanation. This made debugging the issues very difficult. We address that by correctly surfacing the error and relying on a simpler structure of promises.
How?
The issue was because of the way we use webpack in the tests but don't correctly handle errors. Instead of passing an error to the callback, webpack was completing with the errors collected in its stats.
This PR makes the entire test async, and awaits a small promise that just wraps webpack and its callback.
We then check for errors in the webpack stats, and if they're found we throw an
Errorwith the descriptive string produced by webpack.Testing Instructions
CI passes.
I suggest reviewing the changes ignoring whitespace to better see the actual differences.
The snapshots will have different test names ("scripts" is added to the describe title) and the hash will be different due to configuration changes.
This can be tested with a patch like this:
The tests will fail with a message like this: