Vite極速單元測試框架
Vitest
A blazing fast unit test framework powered by Vite.
Documentation | Getting Started | Examples | Why Vitest?
Features
- Vite 's config, transformers, resolvers, and plugins. Use the same setup from your app!
- Jest Snapshot
- Chai built-in for assertions, with Jest expect compatible APIs.
- Smart & instant watch mode , like HMR for tests!
- Native code coverage via c8
- Tinyspy built-in for mocking, stubbing, and spies.
- JSDOM and happy-dom for DOM and browser API mocking
- Components testing ( Vue , React , Svelte , Lit , Vitesse )
- Workers multi-threading via tinypool (a lightweight fork of Piscina )
- ESM first, top level await
- Out-of-box TypeScript / JSX support
- Filtering, timeouts, concurrent for suite and tests
Vitest requires Vite >=v2.7.10 and Node >=v14
import { assert, describe, expect, it } from 'vitest' describe('suite name', () => { it('foo', () => { expect(1 + 1).toEqual(2) expect(true).to.be.true }) it('bar', () => { assert.equal(Math.sqrt(4), 2) }) it('snapshot', () => { expect({ foo: 'bar' }).toMatchSnapshot() }) })
$ npx vitest
Sponsors
Anthony Fu Sponsors
Patak Sponsors
Credits
Thanks to:
- The Jest team and community for creating a delightful testing API
- @lukeed for the work on uvu where we are inspired a lot from.
- @pi0 for the idea and implementation of using Vite to transform and bundle the server code.
- The Vite team for brainstorming the initial idea.
- @patak-dev for the awesome package name!
Contribution
See Contributing Guide .
License
MIT License © 2021-Present Anthony Fu , Matias Capeletto
「其他文章」
- iMile 利用 Zadig 多雲環境周部署千次,跨雲跨地域持續交付全球業務
- 淘寶驚現GitHub“愛國套餐”,其實是刷Star
- 智慧運維實戰:銀行業務流程及單筆交易追蹤
- 圖解OneFlow的學習率調整策略
- 資料資產為王,如何解析企業數字化轉型與資料資產管理的關係?
- 穩!上千微服務接入 Zadig 的最佳姿勢(K8s YAML 篇)
- 20個GitHub倉庫助你成為React大師
- Curve 替換 Ceph 在網易雲音樂的實踐
- 好玩的開源月刊《HelloGitHub》第75期
- Jenkins Github Nginx 實現前端自動化
- 如何將本地已有專案關聯到github的新建的專案中
- 實踐分享| Apache Linkis自定義變數介紹
- 作為前端,要學會用Github Action給自己的專案加上CICD
- github 進不去怎麼辦 || 怎麼訪問 github (超級簡單)
- 叮,GitHub 到賬 550 美元「GitHub 熱點速覽 v.22.26」
- 好用到爆!GitHub 星標 32.5k 的命令列軟體管理神器,功能真心強大!
- 叮,GitHub 到賬 550 美元「GitHub 熱點速覽 v.22.26」
- 修復突然斷電後 git 倉庫 corrupt
- 盤點 6 月 yyds 的開源專案!
- 純golang實現的圖表庫