Skip to content

chore: update Svelte to use Testing Library#2173

Merged
crutchcorn merged 1 commit into
mainfrom
svelte-testing-library
May 10, 2026
Merged

chore: update Svelte to use Testing Library#2173
crutchcorn merged 1 commit into
mainfrom
svelte-testing-library

Conversation

@crutchcorn
Copy link
Copy Markdown
Member

@crutchcorn crutchcorn commented May 10, 2026

Fixes #2161

Summary by CodeRabbit

  • Tests
    • Updated test infrastructure for improved maintainability and consistency across test files.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

All four test files in the packages/svelte-form/tests/ directory were refactored from Svelte's mount/unmount lifecycle to @testing-library/svelte's render API. Test setup now includes automatic cleanup via afterEach, and each test renders its form per test and queries DOM elements from the returned container.

Changes

Svelte Test Infrastructure Refactor

Layer / File(s) Summary
Test Setup Infrastructure
packages/svelte-form/tests/test-setup.ts
Added cleanup hook from @testing-library/svelte and wired it to Vitest's afterEach to clean up the DOM after each test.
Simple Test Refactor
packages/svelte-form/tests/simple.test.ts
Updated imports to use render instead of mount/unmount; replaced per-test manual DOM setup with render(TestForm) and refactored all test assertions to query the returned container. Introduced shared userEvent.setup() instance.
Large Test Refactor
packages/svelte-form/tests/large.test.ts
Updated imports to use render and userEvent.setup(); refactored "initial values" and "mirror user input" tests to render the form and assert against container queries instead of manually-mounted DOM nodes.
Array Test Refactor
packages/svelte-form/tests/array.test.ts
Updated imports to use render instead of mount/unmount; refactored "array mode" and "swapFieldValues" tests to render forms via render() and perform click-driven assertions using the returned container.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 From mount to render, our tests now sing,
Each form springs forth with a cleanup wing,
No manual DOM, just container and care,
Testing Library's dance—so clean and fair! 🧹✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete; it only references the issue number without providing details about the changes or completing the required template sections. Complete the description template by adding a '## 🎯 Changes' section explaining what was refactored and why, and verify the checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: update Svelte to use Testing Library' clearly and concisely describes the main change: migrating Svelte tests to use Testing Library.
Linked Issues check ✅ Passed The PR successfully refactors Svelte tests to use Testing Library across array.test.ts, large.test.ts, simple.test.ts, and test-setup.ts, matching the objective in #2161.
Out of Scope Changes check ✅ Passed All changes are directly related to refactoring Svelte tests to use Testing Library, as specified in issue #2161; no out-of-scope modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch svelte-testing-library

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 10, 2026

View your CI Pipeline Execution ↗ for commit 4f21455

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 32s View ↗
nx run-many --target=build --exclude=examples/** ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-10 23:34:15 UTC

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 10, 2026

More templates

@tanstack/angular-form

npm i https://pkg.pr.new/@tanstack/angular-form@2173

@tanstack/form-core

npm i https://pkg.pr.new/@tanstack/form-core@2173

@tanstack/form-devtools

npm i https://pkg.pr.new/@tanstack/form-devtools@2173

@tanstack/lit-form

npm i https://pkg.pr.new/@tanstack/lit-form@2173

@tanstack/preact-form

npm i https://pkg.pr.new/@tanstack/preact-form@2173

@tanstack/react-form

npm i https://pkg.pr.new/@tanstack/react-form@2173

@tanstack/react-form-devtools

npm i https://pkg.pr.new/@tanstack/react-form-devtools@2173

@tanstack/react-form-nextjs

npm i https://pkg.pr.new/@tanstack/react-form-nextjs@2173

@tanstack/react-form-remix

npm i https://pkg.pr.new/@tanstack/react-form-remix@2173

@tanstack/react-form-start

npm i https://pkg.pr.new/@tanstack/react-form-start@2173

@tanstack/solid-form

npm i https://pkg.pr.new/@tanstack/solid-form@2173

@tanstack/solid-form-devtools

npm i https://pkg.pr.new/@tanstack/solid-form-devtools@2173

@tanstack/svelte-form

npm i https://pkg.pr.new/@tanstack/svelte-form@2173

@tanstack/vue-form

npm i https://pkg.pr.new/@tanstack/vue-form@2173

commit: 4f21455

@sentry
Copy link
Copy Markdown

sentry Bot commented May 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.31%. Comparing base (6892ed0) to head (4f21455).
⚠️ Report is 212 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2173      +/-   ##
==========================================
- Coverage   90.35%   86.31%   -4.04%     
==========================================
  Files          38        8      -30     
  Lines        1752       95    -1657     
  Branches      444        8     -436     
==========================================
- Hits         1583       82    -1501     
+ Misses        149       12     -137     
+ Partials       20        1      -19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@crutchcorn crutchcorn merged commit 087aee7 into main May 10, 2026
7 of 9 checks passed
@crutchcorn crutchcorn deleted the svelte-testing-library branch May 10, 2026 23:34
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.

Refactor Svelte tests to use Testing Library

1 participant