Repository navigation
Align the Vitest setup with the WordPress migration guide - #153
Merged
Merged
Conversation
Import the test API from vitest instead of enabling globals, state the mock cleanup options explicitly (the Vitest 5 defaults the suite relies on), declare the installed Vite 8 as a direct dev dependency, and use a plain vitest.config.mjs as the guide and the other ATE plugins do.
Contributor
Test in WordPress PlaygroundTest the plugin with the code from this branch:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #153 +/- ##
=========================================
Coverage 96.43% 96.43%
Complexity 806 806
=========================================
Files 36 36
Lines 4238 4238
=========================================
Hits 4087 4087
Misses 151 151
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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.
Summary
Aligns the Vitest setup with the
@wordpress/scriptsVitest migration guide.globals: false: every test file importsdescribe,it,expect, the hooks andvifromvitest, as the guide recommends.clearMocks: true,mockReset: falseandrestoreMocks: falseare set explicitly. These are the Vitest 5 defaults the suite already ran with, so behaviour is unchanged, but a future change of defaults can no longer alter it.viteis declared as a direct dev dependency (the guide asks for Vitest and Vite as direct dependencies). It is pinned to the 8.1.5 already in the lockfile; no version moved, the lockfile only drops"peer": trueflags.vitest.config.mts→vitest.config.mjs(its content was plain JavaScript)..distignorealready excludes/vitest.config.*.Kept as is, on purpose:
vitest run --coveragedirectly rather thanwp-scripts test-unit-js: the plugin does not use@wordpress/scripts, and the guide lists the wrapper as an option for projects that already do.Testing
rm -rf node_modules && npm ci && npm run test:js: 258/258, 95.84% lines — identical tomain. TheDOMException … Iframe page loading is disabledlines in the output are unchanged too (129 before and after); they come from happy-dom's disabled iframe loading.