Vitest All In One
Vitest All In One
Vite + Test
Next Generation Testing Framework.
A Vite-native testing framework.
# Vitest requires Vite >=v3.0.0 and Node >=v14.18
$ npm i -D vitest
https://github.com/vitest-dev/vitest
https://vitest.dev/guide/why.html
Mock Functions
mock
&spyOn
// vi ❓vim
import { vi } from 'vitest'
const fn = vi.fn()
fn('hello world')
fn.mock.calls[0] === ['hello world']
const market = {
getApples: () => 100
}
const getApplesSpy = vi.spyOn(market, 'getApples')
market.getApples()
getApplesSpy.mock.calls.length === 1
https://vitest.dev/api/mock.html
demos
https://stackblitz.com/edit/vitest-dev-vitest-rm2j5o?initialPath=vitest/
(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!
https://vueschool.io/lessons/how-to-install-vitest
refs
https://stackoverflow.com/questions/77237009/running-vitest-on-compiled-javascript
©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/17750401.html
未经授权禁止转载,违者必究!