Skip to content

docs: add "Learn" section#10092

Merged
sheremet-va merged 13 commits intovitest-dev:mainfrom
sheremet-va:docs/add-learning-section
Apr 8, 2026
Merged

docs: add "Learn" section#10092
sheremet-va merged 13 commits intovitest-dev:mainfrom
sheremet-va:docs/add-learning-section

Conversation

@sheremet-va
Copy link
Copy Markdown
Member

@sheremet-va sheremet-va commented Apr 7, 2026

This PR adds a new "Learn" section meant to provide more context to new developers or those coming from a different test runner. Most of them could be useful in isolation too.

I have also cleaned up "Getting Started" by removing too advanced examples or moving them to other parts

  • Writing Tests
  • Using Matchers
  • Testing Async Code
  • Setup and Teardown
  • Mock Functions
  • Snapshot Testing
  • Testing in Practice
  • Debugging Tests
  • Writing Tests with AI

This was originally generated with Claude and reviewed and improved by me. The documentation structure is based on Jest

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 7, 2026

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit ac39bee
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69d61fdc86baea0008bcad58
😎 Deploy Preview https://deploy-preview-10092--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Thanks for choosing Vitest!
-->

## Using Unreleased Commits
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is moved to CONTRIBUTING

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new “Learn” tutorial track within the Vitest docs to guide developers through core testing concepts, and wires it into the site navigation while adding cross-links from existing reference guides.

Changes:

  • Add a new /guide/learn/* tutorial series (writing tests, matchers, async, setup/teardown, mocking, snapshots, debugging, and AI-assisted test writing).
  • Update the docs sidebar to include the new Learn section and refine some Mocking sidebar labels.
  • Add “start here” tips from existing guides to the new Learn tutorials, and relocate/condense some Getting Started and configuration-related content.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
docs/guide/why.md Refines the Vite-related note to better set expectations and link to Vite learning material.
docs/guide/snapshot.md Adds a tip pointing beginners to the Learn snapshot tutorial.
docs/guide/mocking.md Adds a tip pointing beginners to the Learn mock-functions tutorial.
docs/guide/lifecycle.md Adds a tip pointing beginners to the Learn setup/teardown tutorial.
docs/guide/learn/writing-tests.md New Learn tutorial covering core test structure, files, output, filtering, globals, and execution model.
docs/guide/learn/matchers.md New Learn tutorial introducing common expect matchers and patterns.
docs/guide/learn/async.md New Learn tutorial for async testing patterns (async/await, resolves/rejects, callbacks, timeouts).
docs/guide/learn/setup-teardown.md New Learn tutorial for hooks, cleanup patterns, and fixtures via test.extend.
docs/guide/learn/mock-functions.md New Learn tutorial for vi.fn, return values, implementations, spying, cleanup, and module mocking.
docs/guide/learn/snapshots.md New Learn tutorial covering snapshot concepts, inline snapshots, updates, and best use cases.
docs/guide/learn/testing-in-practice.md New Learn tutorial on what to test, structuring tests, mocking decisions, and organizing suites.
docs/guide/learn/debugging-tests.md New Learn tutorial on reading failures, isolating issues, common causes, and debugging tooling.
docs/guide/learn/writing-tests-with-ai.md New Learn tutorial on prompting/reviewing AI-generated tests and common pitfalls.
docs/guide/index.md Adds next-step navigation into Learn, condenses sections, and updates links to config/CLI docs.
docs/guide/features.md Adds a tip directing new users to Learn first and updates the configuration link.
docs/config/index.md Adds an “Automatic Dependency Installation” section (moved from Getting Started).
docs/.vitepress/config.ts Adds Learn sidebar group; updates Mocking sub-item labels (Dates/Functions/etc.).
CONTRIBUTING.md Adds “Using Unreleased Commits” guidance (moved from Getting Started).

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@hi-ogawa hi-ogawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The structure looks good to me.
writing-tests-with-ai.html looks quite new, but can this be separate from the PR? I feel this would need a separate aspect of review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 6 comments.


### Are snapshot tests overused?

AI loves snapshot tests because they're easy to generate: just call `toMatchSnapshot()` on everything. But snapshots should be used deliberately for structured output (HTML, error messages, serialized data), not as a lazy substitute for specific assertions.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this opposite? They prefer weaker test without snapshot and they avoid snapshot because they often feels they need to write the snapshot value "by hand" instead of generating by --update.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, in my experience it prefers to use toContain over anything else

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the section. the weaker test is covered by "Do the tests actually assert something meaningful?" in my opinion

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking, but this looks like a good place to also mention bug fix scenario where it describes three steps of

  • write reproduction test case
  • fix
  • confirm test passes

This is something agents should also do to help avoiding hallcinated fix.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the section

@sheremet-va sheremet-va requested a review from hi-ogawa April 8, 2026 09:37
Copy link
Copy Markdown
Collaborator

@hi-ogawa hi-ogawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@sheremet-va sheremet-va merged commit 39b3c85 into vitest-dev:main Apr 8, 2026
10 checks passed
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.

4 participants