Skip to content

Commit fda2d97

Browse files
lonewolfyxNoiseFan
andauthored
docs(cn): translate "Vitest UI -> Module Graph" content (#843)
* docs(cn): translate "Vitest UI -> Module Graph" content * docs(cn): displays some parts of the content in English * docs(cn): displays some parts of the content in English * docs(cn): update "模块运行器" to "ModuleRunner" * docs(cn): transform the local canonical vocabulary * docs(cn): reviewed /guide/ui * docs(cn): update h1 content --------- Co-authored-by: noise <[email protected]>
1 parent cea071c commit fda2d97

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

guide/ui.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Vitest UI | 指南
33
---
44

5-
# Vitest UI
5+
# UI 模式 {#vitest-ui}
66

77
Vitest 由 Vite 提供能力,在运行测试时有一个开发服务器。这允许 Vitest 提供一个漂亮的 UI 界面来查看并与测试交互。Vitest 的 UI 界面是可选的,你可以通过以下安装:
88

@@ -53,91 +53,91 @@ npx vite preview --outDir ./html
5353
你可以使用 [`outputFile`](/config/#outputfile) 配置选项配置输出。你需要在那里指定 `.html` 路径。例如,`./html/index.html` 是默认值。
5454
:::
5555

56-
## Module Graph
56+
## 模块图 {#module-graph}
5757

58-
Module Graph's tab displays the module graph of the selected test file.
58+
模块图选项卡显示所选测试文件的模块图。
5959

6060
::: info
61-
All of the provided images use [Zammad](https://github.com/zammad/zammad) repository as an example.
61+
所有示例图片均使用 [Zammad](https://github.com/zammad/zammad) 代码库作为演示。
6262
:::
6363

6464
<img alt="The module graph view" img-light src="/ui/light-module-graph.png">
6565
<img alt="The module graph view" img-dark src="/ui/dark-module-graph.png">
6666

67-
If there are more than 50 modules, the module graph displays only the first two levels of the graph to reduce the visual clutter. You can always click on "Show Full Graph" icon to preview the full graph.
67+
如果模块数量超过 50 个时,模块图默认仅显示前两层结构以减少视觉干扰。你可以随时点击 "Show Full Graph" 图标来查看完整图表。
6868

6969
<center>
7070
<img alt="The 'Show Full Graph' button located close to the legend" img-light src="/ui/light-ui-show-graph.png">
7171
<img alt="The 'Show Full Graph' button located close to the legend" img-dark src="/ui/dark-ui-show-graph.png">
7272
</center>
7373

7474
::: warning
75-
Note that if your graph is too big, it may take some time before the node positions are stabilized.
75+
注意:如果你的模块规模过大,节点位置可能需要一些时间才能稳定下来。
7676
:::
7777

78-
You can always restore the entry module graph by clicking on "Reset". To expand the module graph, right-click or hold <kbd>Shift</kbd> while clicking the node that interests you. It will display all nodes related to the selected one.
78+
你可以随时点击 "Reset" 来恢复入口模块图。右键点击或按住 <kbd>Shift</kbd> 键,可展开查看与改节点相关的所有模块。
7979

80-
By default, Vitest doesn't show the modules from `node_modules`. Usually, these modules are externalized. You can enable them by deselecting "Hide node_modules".
80+
默认情况下,Vitest 会隐藏 `node_modules` 中的模块。通常,这些模块会被外部化。可以取消勾选 "Hide node_modules" 来显示它们。
8181

82-
### Module Info
82+
### 模块信息 {#module-info}
8383

84-
By left-clicking on the module node, you open the Module Info view.
84+
通过左键点击模块节点,你可以打开模块信息视图。
8585

8686
<img alt="The module info view for an inlined module" img-light src="/ui/light-module-info.png">
8787
<img alt="The module info view for an inlined module" img-dark src="/ui/dark-module-info.png">
8888

89-
This view is separated into two parts. The top part shows the full module ID and some diagnostics about the module. If [`experimental.fsModuleCache`](/config/experimental#experimental-fsmodulecache) is enabled, there will be a "cached" or "not cached" badge. On the right you can see time diagnostics:
89+
此视图分为上下两部分。顶部显示完整的模块 ID 和一些关于模块的诊断信息。如果启用了 [`experimental.fsModuleCache`](/config/experimental#experimental-fsmodulecache),将会显示 "cached" "not cached" 的徽章。在右侧你可以看到时间诊断信息:
9090

91-
- Self Time: the time it took to import the module, excluding static imports.
92-
- Total Time: the time it took to import the module, including static imports. Note that this does not include `transform` time of the current module.
93-
- Transform: the time it took to transform the module.
91+
- 自身时间:导入模块所花费的时间,不包括静态导入。
92+
- 总耗时:导入模块所花费的时间,包括静态导入。请注意,这不包括当前模块的 `transform` 时间。
93+
- 转换:转换模块所花费的时间。
9494

95-
If you opened this view by clicking on an import, you will also see a "Back" button at the start that will take you to the previous module.
95+
若你是通过点击导入项打开此视图,你还会在顶部看到一个 "Back" 按钮,点击可返回上一个模块。
9696

97-
The bottom part depends on the module type. If the module is external, you will only see the source code of that file. You will not be able to traverse the module graph any further, and you won't see how long it took to import static imports.
97+
底部显示内容取决于模块类型。对于外部模块,你仅能看到该文件的源代码。此时无法继续遍历模块依赖图,也无法查看静态导入的耗时情况。
9898

9999
<img alt="The module info view for an external module" img-light src="/ui/light-module-info-external.png">
100100
<img alt="The module info view for an external module" img-dark src="/ui/dark-module-info-external.png">
101101

102-
If the module was inlined, you will see three more windows:
102+
如果模块是内联的,你将看到另外三个窗口:
103103

104-
- Source: unchanged source code of the module
105-
- Transformed: the transformed code that Vitest executes using Vite's [module runner](https://vite.dev/guide/api-environment-runtimes#modulerunner)
106-
- Source Map (v3): source map mappings
104+
- 源代码:模块未更改的源代码
105+
- 转换后:Vitest 使用 Vite[ModuleRunner](https://cn.vite.dev/guide/api-environment-runtimes#modulerunner) 执行的转换后代码
106+
- Source Map (v3):源码映射关系
107107

108-
All static imports in the "Source" window show a total time it took to evaluate them by the current module. If the import was already evaluated in the module graph, it will show `0ms` because it is cached by that point.
108+
"Source" 窗口中的所有静态导入显示当前模块评估它们的总耗时。如果导入已在模块图中被评估过,它将显示 `0ms`,因为此时已被缓存。
109109

110-
If the module took longer than 500 milliseconds to load, the time will be displayed in red. If the module took longer than 100 milliseconds, the time will be displayed in orange.
110+
如果模块加载时间超过 500 毫秒,时间将以红色显示。如果模块加载时间超过 100 毫秒,时间将以橙色显示。
111111

112-
You can click on an import source to jump into that module and traverse the graph further (note `./support/assertions/index.ts` below).
112+
你可以点击导入源代码跳转到该模块并进一步遍历图表(注意下面的 `./support/assertions/index.ts`)。
113113

114114
<img alt="The module info view for an internal module" img-light src="/ui/light-module-info-traverse.png">
115115
<img alt="The module info view for an internal module" img-dark src="/ui/dark-module-info-traverse.png">
116116

117117
::: warning
118-
Note that type-only imports are not executed at runtime and do not display a total duration. They also cannot be opened.
118+
请注意,仅类型导入在运行时不执行,不显示总耗时。它们也无法打开。
119119
:::
120120

121-
If another plugin injects a module import during transformation, those imports will be displayed at the start of the module in gray colour (for example, modules injected by `import.meta.glob`). They also show the total time and can be traversed further.
121+
如果另一个插件在转换期间注入模块导入,这些导入将在模块开始处以灰色显示(例如,通过 `import.meta.glob` 注入的模块)。它们也显示总耗时并且可以进一步遍历。
122122

123123
<img alt="The module info view for an internal module" img-light src="/ui/light-module-info-shadow.png">
124124
<img alt="The module info view for an internal module" img-dark src="/ui/dark-module-info-shadow.png">
125125

126126
::: tip
127-
If you are developing a custom integration on top of Vitest, you can use [`vitest.experimental_getSourceModuleDiagnostic`](/api/advanced/vitest#getsourcemodulediagnostic) to retrieve this information.
127+
如果你正在基于 Vitest 开发自定义集成,可以使用 [`vitest.experimental_getSourceModuleDiagnostic`](/api/advanced/vitest#getsourcemodulediagnostic) 来检索此信息。
128128
:::
129129

130-
### Import Breakdown
130+
### 导入耗时分析 {#import-breakdown}
131131

132-
The Module Graph tab also provides an Import Breakdown with a list of modules that take the longest time to load (top 10 by default, but you can press "Show more" to load 10 more), sorted by Total Time.
132+
模块图选项卡还会提供导入耗时分析功能,默认显示加载时间最长的10个模块(点击"显示更多"可追加10个),按总耗时排序。
133133

134134
<img alt="Import breakdown with a list of top 10 modules that take the longest time to load" img-light src="/ui/light-import-breakdown.png">
135135
<img alt="Import breakdown with a list of top 10 modules that take the longest time to load" img-dark src="/ui/dark-import-breakdown.png">
136136

137-
You can click on the module to see the Module Info. If the module is external, it will have the yellow color (the same color in the module graph).
137+
你可以点击模块查看模块信息。如果模块是外部的,它将显示黄色(与模块图中的颜色相同)。
138138

139-
The breakdown shows a list of modules with self time, total time, and a percentage relative to the time it took to load the whole test file.
139+
分析列表包含自用耗时、总耗时以及相对于加载整个测试文件所花费时间的百分比。
140140

141-
The "Show Import Breakdown" icon will have a red color if there is at least one file that took longer than 500 milliseconds to load, and it will be orange if there is at least one file that took longer than 100 milliseconds.
141+
如果至少有一个文件加载时间超过 500 毫秒,"Show Import Breakdown" 图标将显示红色;如果至少有一个文件加载时间超过 100 毫秒,它将显示橙色。
142142

143-
By default, Vitest shows the breakdown automatically if there is at least one module that took longer than 500 milliseconds to load. You can control the behaviour by setting the [`experimental.printImportBreakdown`](/config/experimental#experimental-printimportbreakdown) option.
143+
默认情况下,如果至少有一个模块加载时间超过 500 毫秒,Vitest 会自动显示分析结果。你可以通过设置 [`experimental.printImportBreakdown`](/config/experimental#experimental-printimportbreakdown) 选项来控制此行为。

0 commit comments

Comments
 (0)