Vitest是基于Vite的原生快速单元测试框架。
特性
和 Vite 的配置、转换器、解析器和插件保持一致JestSapshot内置 Chai 用于断言,以及与 Jestexpect 兼容的API支持 Smart和istatwatch模式,如同用于测试的HMR通过 c8 实现的 Nativecodecoverage内置 Tiyspy 用于模拟、打标和监察使用 JSDOM 和 happy-dom 用于 DOM和browserAPImockigCompoetstestig(Vue, React, Lit, Vitesse)Workersmulti-threadigvia tiypool (alightweightforkof Piscia)ESMfirst,toplevelawait开箱即用的TypeScript/JSX支持Filterig,timeouts,cocurretforsuiteadtests示例
import{it,describe,expect,assert}from'vitest'describe('suiteame',()=>{it('foo',()=>{expect(1+1).toEqual(2)expect(true).to.be.true})it('bar',()=>{assert.equal(Math.sqrt(4),2)})it('sapshot',()=>{expect({foo:'bar'}).toMatchSapshot()})})$pxvitest
评论