Skip to content

Align the Vitest setup with the WordPress migration guide - #153

Merged
erseco merged 1 commit into
mainfrom
chore/vitest-alignment
Sep 29, 2026
Merged

erseco merged 1 commit into
mainfrom
chore/vitest-alignment

Conversation

@erseco

@erseco erseco commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Aligns the Vitest setup with the @wordpress/scripts Vitest migration guide.

  • globals: false: every test file imports describe, it, expect, the hooks and vi from vitest, as the guide recommends.
  • clearMocks: true, mockReset: false and restoreMocks: false are 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.
  • vite is 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": true flags.
  • vitest.config.mts → vitest.config.mjs (its content was plain JavaScript). .distignore already excludes /vitest.config.*.

Kept as is, on purpose:

  • happy-dom instead of jsdom: the config relies on happy-dom's iframe-loading settings.
  • vitest run --coverage directly rather than wp-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 to main. The DOMException … Iframe page loading is disabled lines in the output are unchanged too (129 before and after); they come from happy-dom's disabled iframe loading.

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

Copy link
Copy Markdown
Contributor

Test in WordPress Playground

Test the plugin with the code from this branch:

Preview in WordPress Playground

ℹ️ The eXeLearning editor is fetched from the shared release and unpacked into the plugin when the playground boots, so the first load may take a few extra seconds. ELP upload, shortcode, Gutenberg block and preview work normally.

@codecov-commenter

codecov-commenter commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.43%. Comparing base (ae96741) to head (fb2ca38).
⚠️ Report is 2 commits behind head on main.

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           
Flag Coverage Δ
javascript 95.84% <ø> (ø)
php 96.64% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@erseco
erseco merged commit 5e40e52 into main Sep 29, 2026
5 checks passed
@erseco
erseco deleted the chore/vitest-alignment branch September 29, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants