Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
本次 PR 目标是将 docs-cn 内容与 Vitest 1.x 文档体系对齐:依赖版本回退到 v1.6.1、站点配置指向 v1 分支/站点,并对大量指南/API 页面补齐一致的标题锚点与表述,同时重组“浏览器模式”文档结构。
Changes:
- 将项目版本与相关依赖回退/对齐到 Vitest v1.6.1,并引入
simple-git-hooks+lint-staged作为提交前校验。 - 批量为指南/API 文档补充/规范化标题锚点(
{#...}),修正多处链接与表述。 - 将
/guide/browser/*多页内容合并为单页guide/browser.md,并同步更新侧边栏配置。
Reviewed changes
Copilot reviewed 47 out of 49 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | 对齐到 Vitest v1.6.1 依赖版本,并新增 git hooks/lint-staged 配置 |
| eslint.config.js | 调整 ESLint 配置、忽略项与 Markdown 文件规则覆盖 |
| .vitepress/config.ts | 更新站点链接、编辑链接分支、导航与 sidebar 路由分组(guide/api/config) |
| .vitepress/components/FeaturesList.vue | 更新功能列表条目(移除“分片”项) |
| .vitepress/components.d.ts | 调整生成文件的注释位置(prettier-ignore) |
| guide/index.md | 快速起步页面补齐锚点、调整部分文案与示例格式 |
| guide/why.md | 标题/小节补齐锚点 |
| guide/workspace.md | 标题补齐锚点、示例格式化与少量用语调整 |
| guide/using-plugins.md | 更新 Vite 插件文档链接域名 |
| guide/ui.md | 补充版本说明与链接域名更新 |
| guide/testing-types.md | 标题补齐锚点、示例与表述优化 |
| guide/test-context.md | 标题补齐锚点、补充版本警告块与措辞调整 |
| guide/snapshot.md | 标题补齐锚点、示例与术语调整(测试上下文等) |
| guide/reporters.md | 标题补齐锚点、示例格式化、精简内容并增加部分版本提示 |
| guide/mocking.md | 标题补齐锚点、结构调整与大量用语/格式优化 |
| guide/migration.md | 迁移指南内容大幅裁剪并改为面向 v1 的迁移说明/包含示例 |
| guide/in-source.md | 标题补齐锚点、示例/文案微调 |
| guide/improving-performance.md | 内容裁剪,保留与 v1 对齐的核心说明 |
| guide/ide.md | 标题补齐锚点、徽章文案本地化 |
| guide/filtering.md | 标题补齐锚点、示例格式化 |
| guide/features.md | 补齐锚点、示例/文案与链接调整,删除分片相关段落 |
| guide/common-errors.md | 文案与示例结构调整(pool 配置说明等) |
| guide/cli.md | 裁剪/调整命令与选项说明,补齐锚点 |
| guide/cli-table.md | 重排 CLI 选项表格内容与措辞 |
| guide/environment.md | 标题补齐锚点、链接与注释本地化 |
| guide/debugging.md | 结构裁剪,补齐锚点并保留 VS Code/IDE/Inspector 调试内容 |
| guide/comparisons.md | 标题补齐锚点与部分链接/空格调整 |
| guide/extending-matchers.md | 补齐锚点、更新 TS 示例与类型命名 |
| guide/examples/promise-done.md | 新增迁移示例片段(include 文件) |
| guide/browser.md | 新增“浏览器模式”单页文档(替代原 browser 目录多页) |
| guide/browser/index.md | 删除:原浏览器模式 index 页 |
| guide/browser/assertion-api.md | 删除:原断言 API 页 |
| guide/browser/retry-ability.md | 删除:原可重试断言页 |
| guide/browser/context.md | 删除:原 context 页 |
| guide/browser/interactivity-api.md | 删除:原交互 API 页 |
| guide/browser/commands.md | 删除:原 commands 页 |
| guide/browser/examples.md | 删除:原 examples 页 |
| config/file.md | 配置文件说明补齐锚点并优化表述/示例注释 |
| api/index.md | Test API 索引补齐锚点、加入 v1.3.0 起参数形态弃用说明等 |
| api/vi.md | 调整章节标题/文案,并新增浏览器模式限制提示 |
| api/mock.md | 修正少量格式/文案与示例格式化 |
| api/expect.md | 文案本地化与删改部分章节内容(含示例/版本标注调整) |
| api/expect-typeof.md | 调整类型签名位置与示例格式化 |
| advanced/runner.md | 修正 TS 类型示例分隔符并更新链接到 v1 站点 |
| advanced/api.md | 章节标题重命名并裁剪部分模式/方法说明 |
Comments suppressed due to low confidence (1)
guide/extending-matchers.md:37
- 该 TypeScript 声明文件示例里
import type { Assertion, AsymmetricMatchersContaining } from 'vitest'实际未被使用(下面在declare module 'vitest'中又重新声明了同名接口)。在开启noUnusedLocals时,复制此示例可能会产生未使用导入的报错。建议删除该 import,或改为在声明合并中显式使用导入的类型并避免同名声明冲突。
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+59
to
61
| "lint-staged": { | ||
| "*": "eslint --fix" | ||
| } |
| 然后在调试模式下运行此配置。IDE 将在编辑器中设置的 JS/TS 断点处停止。 | ||
|
|
||
| ## Node Inspector, e.g. Chrome DevTools | ||
| ## Node 解释器, 例如 Chrome开发者工具 {#node-inspector-e-g-chrome-devtools} |
| ::: | ||
|
|
||
| ### Github Actions Reporter {#github-actions-reporter} | ||
| ### Github Actions 报告器 <Badge type="info">1.3.0+</Badge> {#github-actions-reporter} |
Comment on lines
274
to
276
| reporters: [ | ||
| [ | ||
| 'junit', | ||
| { suiteName: 'custom suite name', classname: 'custom-classname' }, | ||
| ], | ||
| ['junit', { suiteName: 'custom suite name', classname: 'custom-classname' },], | ||
| ], |
| [浏览器模式](/guide/browser) 目前不支持模拟模块。可以在这个 [issue](https://github.com/vitest-dev/vitest/issues/3046) 中持续关注此功能。 | ||
| ::: | ||
|
|
||
| 如果定义了 `factory`,所有导入都将返回其结果。Vitest 只调用一次 factory,并缓存所有后续导入的结果,直到 [`vi.unmock`](#vii-unmock) 或 [`vi.doUnmock`](#vii-dounmock) 被调用。 |
Comment on lines
+243
to
252
| ### 类型 {#types} | ||
|
|
||
| Vitest 没有等效于 `jest` 的命名空间,因此你需要直接从 `Vitest` 导入类型: | ||
|
|
||
| ```ts | ||
| // [!code --] | ||
| let fn: jest.Mock<(name: string) => number> // [!code --] | ||
| import type { Mock } from 'vitest' // [!code ++] | ||
| let fn: Mock<(name: string) => number> // [!code ++] | ||
| import type { Mock } from 'vitest' | ||
| let fn: jest.Mock<string, [string]> // [!code ++] | ||
| let fn: Mock<[string], string> // [!code ++] | ||
| ``` |
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.
在提交PR之前,请确保您执行以下操作:
fixes #123)。描述
附加上下文