xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

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://vitest.dev/guide/

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

image

https://stackblitz.com/edit/vitest-dev-vitest-rm2j5o?initialPath=vitest/

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, 禁止转载 🈲️,侵权必究⚠️!


posted @   xgqfrms  阅读(4)  评论(2编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2022-10-08 LeetCode 字符串相乘算法题解 All In One
2022-10-08 Game Development Essential Terms All In One
2022-10-08 河南美食-阿利茄汁面 All In One
2021-10-08 Web API appendChild bugs All In One
2021-10-08 三非学校 All In One
2021-10-08 前端页面卡顿问题如何排查 All In One
2020-10-08 API 授权 All In One
点击右上角即可分享
微信分享提示