Skip to content

安装

¥Installation

shell
npm install --save-dev @vue/test-utils
shell
yarn add --dev @vue/test-utils

用法

¥Usage

Vue Test Utils 与框架无关 - 你可以将它与你喜欢的任何测试运行程序一起使用。最简单的尝试方法是使用 Jest,一个流行的测试运行器。

¥Vue Test Utils is framework agnostic - you can use it with whichever test runner you like. The easiest way to try it out is using Jest, a popular test runner.

要使用 Jest 加载 .vue 文件,你将需要 vue-jestvue-jest v5 是支持 Vue 3 的版本。它仍处于 alpha 阶段,与 Vue.js 3 生态系统的其他部分非常相似,因此如果你发现错误,请报告 此处 并注明你正在使用 vue-jest v5。

¥To load .vue files with Jest, you will need vue-jest. vue-jest v5 is the one that supports Vue 3. It is still in alpha, much like the rest of the Vue.js 3 ecosystem, so if you find a bug please report it here and specify you are using vue-jest v5.

你可以使用 vue-jest@next 安装它。然后你需要用 Jest 的 transform 选项来配置它。

¥You can install it with vue-jest@next. Then you need to configure it with Jest's transform option.

如果你不想自己配置,你可以获取一个包含所有设置的最小存储库 此处

¥If you don't want to configure it yourself, you can get a minimal repository with everything set up here.

继续阅读以了解有关 Vue Test Utils 的更多信息。

¥Continue reading to learn more about Vue Test Utils.

VueTestUtils v2.4 中文网 - 粤ICP备13048890号