├── packages
├── web-worker
│ ├── index.d.ts
│ ├── pure.d.ts
│ ├── src
│ │ ├── index.ts
│ │ └── types.ts
│ └── tsconfig.json
├── vite-node
│ ├── .gitignore
│ ├── src
│ │ ├── index.ts
│ │ └── hmr
│ │ │ └── index.ts
│ ├── vite-node.mjs
│ └── tsconfig.json
├── runner
│ ├── types.d.ts
│ ├── utils.d.ts
│ ├── README.md
│ ├── tsconfig.json
│ └── src
│ │ ├── errors.ts
│ │ └── test-state.ts
├── utils
│ ├── diff.d.ts
│ ├── error.d.ts
│ ├── helpers.d.ts
│ ├── source-map.ts
│ └── tsconfig.json
├── vitest
│ ├── index.d.cts
│ ├── node.d.ts
│ ├── src
│ │ ├── utils.ts
│ │ ├── integrations
│ │ │ ├── spy.ts
│ │ │ ├── chai
│ │ │ │ ├── chai-subset.d.ts
│ │ │ │ └── config.ts
│ │ │ ├── utils.ts
│ │ │ ├── globals.ts
│ │ │ └── env
│ │ │ │ └── index.ts
│ │ ├── public
│ │ │ ├── reporters.ts
│ │ │ ├── execute.ts
│ │ │ ├── coverage.ts
│ │ │ ├── utils.ts
│ │ │ ├── runners.ts
│ │ │ ├── snapshot.ts
│ │ │ ├── environments.ts
│ │ │ └── suite.ts
│ │ ├── utils
│ │ │ ├── timers.ts
│ │ │ ├── debugger.ts
│ │ │ ├── source-map.ts
│ │ │ └── figures.ts
│ │ ├── node
│ │ │ ├── cli.ts
│ │ │ ├── reporters
│ │ │ │ ├── html.ts
│ │ │ │ └── benchmark
│ │ │ │ │ └── index.ts
│ │ │ └── types
│ │ │ │ ├── worker.ts
│ │ │ │ └── vite.ts
│ │ ├── typecheck
│ │ │ ├── expectTypeOf.ts
│ │ │ └── assertType.ts
│ │ ├── runtime
│ │ │ └── types
│ │ │ │ └── utils.ts
│ │ ├── types
│ │ │ └── ui.ts
│ │ └── paths.ts
│ ├── suite.d.ts
│ ├── utils.d.ts
│ ├── browser.d.ts
│ ├── config.d.ts
│ ├── coverage.d.ts
│ ├── execute.d.ts
│ ├── runners.d.ts
│ ├── snapshot.d.ts
│ ├── workers.d.ts
│ ├── environments.d.ts
│ ├── reporters.d.ts
│ ├── vitest.mjs
│ ├── importMeta.d.ts
│ ├── jsdom.d.ts
│ ├── tsconfig.json
│ ├── import-meta.d.ts
│ └── README.md
├── snapshot
│ ├── manager.d.ts
│ ├── environment.d.ts
│ ├── src
│ │ └── environment.ts
│ └── tsconfig.json
├── ui
│ ├── client
│ │ ├── composables
│ │ │ ├── index.ts
│ │ │ ├── dark.ts
│ │ │ └── explorer
│ │ │ │ └── index.ts
│ │ ├── App.vue
│ │ └── utils
│ │ │ └── escape.ts
│ ├── public
│ │ └── bg.png
│ ├── reporter.d.ts
│ ├── shim.d.ts
│ ├── tsconfig.json
│ └── README.md
├── expect
│ ├── index.d.ts
│ ├── tsconfig.json
│ └── src
│ │ ├── constants.ts
│ │ └── index.ts
├── spy
│ ├── README.md
│ └── tsconfig.json
├── coverage-istanbul
│ ├── src
│ │ └── constants.ts
│ └── tsconfig.json
├── browser
│ ├── src
│ │ └── client
│ │ │ ├── tester
│ │ │ └── jest-dom.ts
│ │ │ └── ui.ts
│ ├── context.js
│ ├── tsconfig.json
│ ├── types.ts
│ ├── providers.d.ts
│ └── providers
│ │ └── webdriverio.d.ts
├── ws-client
│ └── tsconfig.json
├── coverage-v8
│ └── tsconfig.json
└── pretty-format
│ └── tsconfig.json
├── test
├── watch
│ ├── fixtures
│ │ ├── 42.txt
│ │ ├── force-watch
│ │ │ └── trigger.js
│ │ ├── example.ts
│ │ ├── math.ts
│ │ ├── math.test.ts
│ │ └── single-failed
│ │ │ ├── failed.test.ts
│ │ │ └── basic.test.ts
│ ├── .gitignore
│ └── package.json
├── cli
│ └── fixtures
│ │ ├── fails
│ │ ├── empty.test.ts
│ │ ├── proxy-module.ts
│ │ ├── no-assertions.test.ts
│ │ ├── expect-soft.test.ts
│ │ ├── expect.test.ts
│ │ ├── expect-unreachable.test.ts
│ │ ├── .dot-folder
│ │ │ └── dot-test.test.ts
│ │ ├── primitive-error.test.ts
│ │ ├── each-timeout.test.ts
│ │ ├── test-extend
│ │ │ ├── fixture-rest-params.test.ts
│ │ │ ├── fixture-rest-props.test.ts
│ │ │ ├── fixture-without-destructuring.test.ts
│ │ │ ├── test-rest-params.test.ts
│ │ │ ├── test-rest-props.test.ts
│ │ │ └── test-without-destructuring.test.ts
│ │ ├── mock-import-proxy-module.test.ts
│ │ ├── unhandled.test.ts
│ │ ├── vite.config.ts
│ │ └── hook-timeout.test.ts
│ │ ├── setup-files
│ │ ├── empty-setup.ts
│ │ ├── empty.test.ts
│ │ └── console-setup.ts
│ │ ├── vm-threads
│ │ ├── src
│ │ │ └── external
│ │ │ │ ├── assets
│ │ │ │ ├── file1.png
│ │ │ │ ├── file2.txt
│ │ │ │ └── file3.svg
│ │ │ │ ├── css
│ │ │ │ ├── empty.css
│ │ │ │ ├── processed.css
│ │ │ │ └── processed.module.css
│ │ │ │ ├── package.json
│ │ │ │ ├── primitive-cjs.cjs
│ │ │ │ ├── package-null
│ │ │ │ └── package-null.js
│ │ │ │ ├── export-default-cjs.js
│ │ │ │ ├── default-cjs.cjs
│ │ │ │ ├── export-nested-default-cjs.js
│ │ │ │ └── nested-default-cjs.cjs
│ │ └── vitest.config.ts
│ │ ├── public-api
│ │ └── vitest.config.ts
│ │ ├── git-changed
│ │ ├── related
│ │ │ ├── vitest.config.js
│ │ │ ├── src
│ │ │ │ ├── sourceA.ts
│ │ │ │ ├── sourceB.ts
│ │ │ │ ├── sourceC.ts
│ │ │ │ └── sourceD.ts
│ │ │ └── not-related.test.ts
│ │ └── workspace
│ │ │ ├── vitest.config.mjs
│ │ │ ├── package.json
│ │ │ ├── vitest.workspace.js
│ │ │ └── packages
│ │ │ ├── packageA
│ │ │ ├── index.js
│ │ │ ├── vitest.config.mjs
│ │ │ └── index.test.js
│ │ │ └── packageB
│ │ │ ├── index.js
│ │ │ ├── vitest.config.mjs
│ │ │ └── index.test.js
│ │ ├── list
│ │ ├── top-level-error.test.ts
│ │ ├── math.test.ts
│ │ ├── fail.config.ts
│ │ ├── describe-error.test.ts
│ │ ├── custom.config.ts
│ │ └── vitest.config.ts
│ │ ├── restricted-fs
│ │ ├── vitest.setup.js
│ │ ├── src
│ │ │ └── math.js
│ │ └── tests
│ │ │ └── basic.spec.js
│ │ ├── tty
│ │ ├── example.ts
│ │ ├── math.ts
│ │ ├── math.test.ts
│ │ └── example.test.ts
│ │ ├── custom-pool
│ │ └── tests
│ │ │ ├── custom-not-run.spec.ts
│ │ │ └── custom-run.threads.spec.ts
│ │ ├── stacktraces
│ │ ├── frame.spec.imba
│ │ ├── foo.js
│ │ ├── utils.ts
│ │ ├── require-assertions.test.js
│ │ ├── setup.js
│ │ ├── error-in-deps.test.js
│ │ ├── mocked-global.test.js
│ │ ├── mocked-imported.test.js
│ │ ├── mocked-imported.test.ts
│ │ ├── add-in-js.test.js
│ │ ├── add-in-imba.test.imba
│ │ └── add.test.ts
│ │ ├── global-setup-fail
│ │ ├── globalSetup
│ │ │ └── error.js
│ │ └── example.test.ts
│ │ ├── create-vitest
│ │ ├── vitest.config.ts
│ │ └── basic.test.ts
│ │ ├── vitest.config.js
│ │ ├── inspect
│ │ ├── math.test.ts
│ │ └── vitest.config.ts
│ │ ├── plugin
│ │ └── basic.test.ts
│ │ ├── ws-server-url
│ │ ├── basic.test.ts
│ │ └── vitest.config.ts
│ │ ├── dotted-files
│ │ └── .cache
│ │ │ └── projects
│ │ │ └── test
│ │ │ ├── should-run.test.ts
│ │ │ └── .cache
│ │ │ └── should-not-run.test.ts
│ │ ├── console
│ │ └── vitest.config.ts
│ │ ├── expect-soft
│ │ └── vite.config.ts
│ │ └── custom-file-env
│ │ └── custom-file-env.test.ts
├── core
│ ├── src
│ │ ├── file-txt.txt
│ │ ├── esm
│ │ │ ├── esm.js
│ │ │ ├── internal-esm.mjs
│ │ │ └── package.json
│ │ ├── mocks
│ │ │ ├── dynamic-module.d.ts
│ │ │ ├── dynamic-module.js
│ │ │ ├── moduleA.ts
│ │ │ ├── default.ts
│ │ │ ├── cyclic-deps
│ │ │ │ ├── module-1.mjs
│ │ │ │ ├── module-2.mjs
│ │ │ │ ├── module-3.mjs
│ │ │ │ └── module-4.mjs
│ │ │ ├── squared.js
│ │ │ ├── has space in path.ts
│ │ │ ├── moduleB.ts
│ │ │ ├── external
│ │ │ │ ├── default-cjs.cjs
│ │ │ │ ├── external.mjs
│ │ │ │ ├── default-function.cjs
│ │ │ │ └── cjs-pseudoesm.cjs
│ │ │ ├── A.ts
│ │ │ ├── B.ts
│ │ │ ├── zustand-magic.ts
│ │ │ ├── export-default-circle-b.ts
│ │ │ ├── export-default-circle-index.ts
│ │ │ ├── main.js
│ │ │ ├── integration.ts
│ │ │ ├── set-foo.ts
│ │ │ ├── moduleWithSymbol.ts
│ │ │ └── log.ts
│ │ ├── file-sass.sass
│ │ ├── submodule.ts
│ │ ├── timeout.ts
│ │ ├── aliased-mod.ts
│ │ ├── cjs
│ │ │ ├── array-cjs.js
│ │ │ ├── module-cjs.ts
│ │ │ ├── primitive-cjs.js
│ │ │ ├── promise-export.js
│ │ │ ├── bare-cjs.js
│ │ │ ├── default-function.d.ts
│ │ │ ├── class-cjs.js
│ │ │ ├── default-function.js
│ │ │ ├── nested-default-cjs.js
│ │ │ └── prototype-cjs.js
│ │ ├── external
│ │ │ ├── package.json
│ │ │ ├── pkg-node
│ │ │ │ ├── ssr.js
│ │ │ │ ├── web.js
│ │ │ │ ├── index.d.ts
│ │ │ │ └── package.json
│ │ │ ├── pkg-browser
│ │ │ │ ├── index.d.ts
│ │ │ │ ├── ssr.js
│ │ │ │ ├── web.js
│ │ │ │ └── package.json
│ │ │ ├── default-cjs.js
│ │ │ └── nested-default-cjs.js
│ │ ├── file-css.css
│ │ ├── file-scss.scss
│ │ ├── global-mock.ts
│ │ ├── web-worker
│ │ │ ├── selfWorkerDep.ts
│ │ │ ├── objectWorker.ts
│ │ │ ├── worker.ts
│ │ │ ├── selfWorker.ts
│ │ │ ├── eventListenerWorker.ts
│ │ │ ├── worker-globals.ts
│ │ │ └── sharedWorker.ts
│ │ ├── __mocks__
│ │ │ └── submodule.ts
│ │ ├── wasm
│ │ │ ├── add.wasm
│ │ │ ├── wasm-bindgen
│ │ │ │ ├── package.json
│ │ │ │ ├── index_bg.wasm
│ │ │ │ └── README.md
│ │ │ └── wasm-bindgen-no-cyclic
│ │ │ │ ├── index_bg.wasm
│ │ │ │ ├── index.d.ts
│ │ │ │ ├── index.js
│ │ │ │ └── index_bg.wasm.d.ts
│ │ ├── file-less.less
│ │ ├── mockedA.ts
│ │ ├── module-esm.ts
│ │ ├── in-source
│ │ │ └── index.ts
│ │ ├── env.ts
│ │ ├── self
│ │ │ ├── foo.ts
│ │ │ └── index.ts
│ │ ├── mockedD.ts
│ │ ├── rely-on-hoisted.ts
│ │ ├── mockedB.ts
│ │ ├── relative-import.ts
│ │ ├── dynamic-import.ts
│ │ ├── circularB.ts
│ │ ├── circularA.ts
│ │ ├── read-hello-world.ts
│ │ └── mockedE.ts
│ ├── .env.local
│ ├── test
│ │ ├── fixtures
│ │ │ ├── snapshot-empty.txt
│ │ │ ├── hi.txt
│ │ │ ├── snapshots
│ │ │ │ ├── basic
│ │ │ │ │ ├── output.css
│ │ │ │ │ └── input.json
│ │ │ │ └── multiple
│ │ │ │ │ ├── output.css
│ │ │ │ │ └── input.json
│ │ │ ├── increment.ts
│ │ │ ├── hello-mock.ts
│ │ │ └── mocked-dependency.ts
│ │ ├── timers-node.test.ts
│ │ ├── timers-jsdom.test.ts
│ │ ├── setup.ts
│ │ ├── __snapshots__
│ │ │ ├── nested-suite.test.ts.snap
│ │ │ ├── suite.test.tsx.snap
│ │ │ ├── snapshot-concurrent-sync.test.ts.snap
│ │ │ └── snapshot-concurrent.test.ts.snap
│ │ ├── moved-snapshot.test.ts.snap
│ │ ├── moved-snapshot.test.ts
│ │ ├── stubbed-process.test.ts
│ │ ├── self.test.ts
│ │ ├── env-glob.test.ts
│ │ ├── env-glob-dom
│ │ │ ├── env-glob.spec.ts
│ │ │ └── env-glob.overrides.spec.ts
│ │ ├── env-glob.dom.test.ts
│ │ ├── alias.test.ts
│ │ ├── inlined.test.ts
│ │ ├── snapshots-outside.ts
│ │ ├── isolate.test.ts
│ │ ├── mocking
│ │ │ ├── custom-module-directory.spec.ts
│ │ │ ├── has-extension.spec.ts
│ │ │ ├── spaced.spec.ts
│ │ │ └── integration.test.ts
│ │ ├── builtin.test.ts
│ │ ├── dom-single-line-options.test.ts
│ │ ├── external-module-directory.test.ts
│ │ ├── mocked-no-mocks-same.test.ts
│ │ ├── snapshot-concurrent-sync.test.ts
│ │ ├── skip-reset-state.test.ts
│ │ ├── jest-expect-no-url.test.ts
│ │ └── environments
│ │ │ ├── custom-env.test.ts
│ │ │ └── node.spec.ts
│ ├── __mocks__
│ │ ├── extension.js.ts
│ │ ├── vscode-mocks.ts
│ │ ├── virtual-module.ts
│ │ ├── timers.ts
│ │ ├── custom-lib.ts
│ │ ├── axios.ts
│ │ ├── fs.cjs
│ │ ├── fs
│ │ │ └── promises.cjs
│ │ ├── @vueuse
│ │ │ └── integrations
│ │ │ │ └── useJwt.ts
│ │ └── zustand.ts
│ ├── deps
│ │ ├── dep2
│ │ │ ├── index.js
│ │ │ └── package.json
│ │ └── dep1
│ │ │ ├── package.json
│ │ │ └── esm
│ │ │ └── index.js
│ ├── projects
│ │ ├── custom-lib
│ │ │ ├── package.json
│ │ │ └── index.js
│ │ └── inline-lib
│ │ │ ├── package.json
│ │ │ └── index.js
│ ├── vitest-environment-custom
│ │ └── package.json
│ ├── index.html
│ └── types
│ │ └── env.d.ts
├── workspaces
│ ├── .gitignore
│ ├── space_1
│ │ ├── .env.local
│ │ ├── test
│ │ │ ├── happy-dom.spec.ts
│ │ │ └── math.spec.ts
│ │ └── vite.config.ts.timestamp-4345324-324424.mjs
│ ├── space_3
│ │ ├── package.json
│ │ ├── src
│ │ │ └── multiply.ts
│ │ ├── localSetup.ts
│ │ ├── vitest.config.ts
│ │ ├── global-provide.space-3-test.ts
│ │ ├── vite.config.ts
│ │ └── math.space-3-test.ts
│ ├── space_shared
│ │ ├── setup.node.ts
│ │ ├── setup.jsdom.ts
│ │ └── test.spec.ts
│ ├── .env.local
│ ├── cwdPlugin.d.ts
│ ├── space_2
│ │ └── test
│ │ │ └── node.spec.ts
│ ├── coverage-report-tests
│ │ └── vitest.config.ts
│ ├── space-multi-transform
│ │ └── test
│ │ │ ├── project-1.test.ts
│ │ │ └── project-2.test.ts
│ ├── src
│ │ └── math.ts
│ └── cwdPlugin.js
├── reporters
│ ├── .gitignore
│ ├── fixtures
│ │ ├── .gitignore
│ │ ├── merge-reports
│ │ │ └── vitest.config.js
│ │ ├── invalid-diff-config.ts
│ │ ├── json-fail-import.test.ts
│ │ ├── ok.test.ts
│ │ ├── vitest.config.ts
│ │ ├── custom-diff-config.ts
│ │ ├── custom-error
│ │ │ ├── vitest.config.ts
│ │ │ └── basic.test.ts
│ │ ├── better-testsuite-name
│ │ │ ├── vitest.config.ts
│ │ │ ├── vitest.workspace.ts
│ │ │ ├── space-1
│ │ │ │ └── test
│ │ │ │ │ └── base.test.ts
│ │ │ └── space-2
│ │ │ │ └── test
│ │ │ │ └── base.test.ts
│ │ ├── suite-hook-failure
│ │ │ └── vitest.config.ts
│ │ ├── with-syntax-error.test.js
│ │ ├── custom-diff-config.test.ts
│ │ ├── duration
│ │ │ ├── vitest.config.ts
│ │ │ └── basic.test.ts
│ │ ├── error-to-json.test.ts
│ │ ├── console-simple.test.ts
│ │ ├── some-failing.test.ts
│ │ ├── default
│ │ │ ├── MockReporter.ts
│ │ │ └── vitest.config.ts
│ │ ├── all-skipped.test.ts
│ │ ├── all-passing-or-skipped.test.ts
│ │ ├── code-frame-line-limit.test.ts
│ │ ├── json-fail.test.ts
│ │ ├── error-props
│ │ │ └── basic.test.ts
│ │ ├── indicator-position.test.js
│ │ └── function-as-name.bench.ts
│ ├── tsconfig.json
│ ├── reportPkg
│ │ ├── package.json
│ │ └── index.js
│ ├── without-custom-reporter.vitest.config.ts
│ ├── src
│ │ └── custom-reporter.js
│ ├── custom-reporter.vitest.config.ts
│ └── deps-reporter.vitest.config.ts
├── vite-node
│ ├── .env.local
│ ├── src
│ │ ├── deps.css
│ │ ├── circular1
│ │ │ ├── a.ts
│ │ │ ├── b.ts
│ │ │ └── index.ts
│ │ ├── foo.js
│ │ ├── watch
│ │ │ ├── index.cjs
│ │ │ ├── index.js
│ │ │ └── index.mjs
│ │ ├── cli-parse-args.js
│ │ ├── circular2
│ │ │ ├── c.ts
│ │ │ ├── a.ts
│ │ │ ├── reg.ts
│ │ │ ├── b.ts
│ │ │ └── index.ts
│ │ ├── cli-print-env.js
│ │ ├── self-export.js
│ │ ├── hmr-script.js
│ │ ├── testMod.ts
│ │ ├── self-export-example2.ts
│ │ ├── self-export.d.ts
│ │ ├── deps.ts
│ │ ├── self-export-example1.ts
│ │ └── main.ts
│ └── vitest.config.ts
├── global-setup
│ ├── index.html
│ ├── package.json
│ └── setupFiles
│ │ └── without-relative-path-prefix.ts
├── ui
│ ├── .gitignore
│ ├── fixtures
│ │ ├── coverage.ts
│ │ ├── coverage.test.ts
│ │ ├── task-name.test.ts
│ │ ├── error.test.ts
│ │ └── sample.test.ts
│ ├── tsconfig.json
│ ├── vitest.config.ts
│ └── playwright.config.ts
├── workspaces-browser
│ ├── .gitignore
│ ├── space_browser_inline
│ │ └── test-alias-to.ts
│ ├── space_1
│ │ ├── test
│ │ │ ├── node.spec.ts
│ │ │ └── math.spec.ts
│ │ ├── vite.config.ts
│ │ └── vitest.config.ts.timestamp-4345324-324424.mjs
│ ├── space_browser
│ │ ├── test
│ │ │ └── browser.spec.ts
│ │ └── vitest.config.ts
│ ├── package.json
│ └── src
│ │ └── math.ts
├── config
│ ├── fixtures
│ │ ├── pass-empty-files
│ │ │ └── empty.test.ts
│ │ ├── shard
│ │ │ ├── vitest.config.js
│ │ │ └── test
│ │ │ │ ├── 1.test.js
│ │ │ │ ├── 2.test.js
│ │ │ │ └── 3.test.js
│ │ ├── base-path
│ │ │ └── src
│ │ │ │ └── index.ts
│ │ ├── workers-option
│ │ │ ├── vitest.config.js
│ │ │ └── example.test.ts
│ │ ├── vitest.config.js
│ │ ├── conditions-subpackage
│ │ │ ├── custom.js
│ │ │ ├── production.js
│ │ │ ├── development.js
│ │ │ ├── default.js
│ │ │ └── package.json
│ │ ├── workspace-flags
│ │ │ ├── projects
│ │ │ │ ├── vitest.config.js
│ │ │ │ └── cli-config.test.ts
│ │ │ └── vitest.workspace.js
│ │ ├── workspace
│ │ │ ├── nested
│ │ │ │ └── e2e.projects.js
│ │ │ ├── project-1
│ │ │ │ └── calculator-1.test.ts
│ │ │ ├── project-2
│ │ │ │ └── calculator-2.test.ts
│ │ │ └── browser
│ │ │ │ └── workspace-with-browser.ts
│ │ ├── css
│ │ │ ├── App.css
│ │ │ └── App.module.css
│ │ ├── conditions-pkg
│ │ │ ├── index.js
│ │ │ └── package.json
│ │ ├── project
│ │ │ ├── vitest.workspace.ts
│ │ │ ├── vitest.config.ts
│ │ │ └── packages
│ │ │ │ ├── project_1
│ │ │ │ └── base.test.ts
│ │ │ │ ├── project_2
│ │ │ │ └── base.test.ts
│ │ │ │ └── space_1
│ │ │ │ └── base.test.ts
│ │ ├── exclude
│ │ │ ├── math.ts
│ │ │ ├── string.ts
│ │ │ ├── math.test.ts
│ │ │ ├── vitest.exclude.config.ts
│ │ │ └── string.test.ts
│ │ ├── filters-slash
│ │ │ ├── test
│ │ │ │ ├── basic.test.ts
│ │ │ │ ├── basic-foo
│ │ │ │ │ └── a.test.ts
│ │ │ │ ├── basic
│ │ │ │ │ └── a.test.ts
│ │ │ │ └── foo-basic
│ │ │ │ │ └── a.test.ts
│ │ │ └── vitest.config.ts
│ │ ├── console
│ │ │ ├── vitest.config.ts
│ │ │ └── basic.test.ts
│ │ ├── chai-config
│ │ │ └── vitest.config.ts
│ │ ├── conditions-test
│ │ │ ├── vitest.config.ts
│ │ │ └── conditions.test.js
│ │ ├── console-color
│ │ │ ├── vitest.config.ts
│ │ │ └── basic.test.ts
│ │ ├── test
│ │ │ ├── vitest.config.js
│ │ │ ├── example.test.ts
│ │ │ └── fake-timers.test.ts
│ │ ├── cache
│ │ │ └── basic.test.ts
│ │ ├── mode
│ │ │ ├── example.test.ts
│ │ │ ├── example.benchmark.ts
│ │ │ ├── vitest.test.config.ts
│ │ │ └── vitest.benchmark.config.ts
│ │ ├── no-exec-args-fixtures
│ │ │ └── vitest.config.ts
│ │ ├── allowed-exec-args-fixtures
│ │ │ └── vitest.config.ts
│ │ ├── filters
│ │ │ └── test
│ │ │ │ ├── example.test.ts
│ │ │ │ ├── config.test.ts
│ │ │ │ └── dont-run-this.test.ts
│ │ ├── mixed-environments
│ │ │ ├── vitest.config.ts
│ │ │ └── project
│ │ │ │ └── test
│ │ │ │ └── workspace-project.test.ts
│ │ └── retry
│ │ │ ├── vitest.config.ts
│ │ │ └── retry.test.ts
│ ├── tsconfig.json
│ └── package.json
├── browser
│ ├── injected-lib
│ │ ├── index.js
│ │ └── package.json
│ ├── cjs-lib
│ │ ├── lib.d.ts
│ │ ├── lib.mjs
│ │ ├── index.js
│ │ └── package.json
│ ├── test
│ │ ├── __snapshots__
│ │ │ ├── custom
│ │ │ │ └── my_snapshot
│ │ │ └── snapshot.test.ts.snap
│ │ ├── another.test.ts
│ │ ├── failing.snaphot.test.ts
│ │ ├── server-headers.test.ts
│ │ ├── utils.test.ts
│ │ ├── injected.test.ts
│ │ ├── polyfill-lib.test.ts
│ │ ├── failing.test.ts
│ │ └── dialog.test.ts
│ ├── custom-snapshot-env.ts
│ ├── fixtures
│ │ ├── update-snapshot
│ │ │ └── __snapshots__
│ │ │ │ ├── custom
│ │ │ │ └── my_snapshot
│ │ │ │ └── basic.test.ts.snap
│ │ ├── mocking
│ │ │ ├── src
│ │ │ │ ├── nested_child.ts
│ │ │ │ ├── actions.ts
│ │ │ │ ├── __mocks__
│ │ │ │ │ └── mocks_calculator.ts
│ │ │ │ ├── nested_parent.ts
│ │ │ │ ├── mocks_factory.ts
│ │ │ │ ├── calculator.ts
│ │ │ │ └── mocks_calculator.ts
│ │ │ ├── not-mocked-nested.test.ts
│ │ │ ├── not-mocked.test.ts
│ │ │ ├── mocked-__mocks__.test.ts
│ │ │ ├── automocked.test.ts
│ │ │ └── mocking-dep.test.ts
│ │ ├── server-url
│ │ │ └── basic.test.ts
│ │ └── mocking-watch
│ │ │ ├── 2_not-mocked-import.test.ts
│ │ │ └── 1_mocked-on-watch-change.test.ts
│ ├── src
│ │ ├── __mocks__
│ │ │ └── _calculator.ts
│ │ ├── actions.ts
│ │ ├── createNode.ts
│ │ ├── error.ts
│ │ └── calculator.ts
│ ├── injected.ts
│ ├── custom-diff-config.ts
│ ├── vitest.config-basepath.mts
│ └── tsconfig.json
├── typescript
│ ├── fixtures
│ │ └── source-error
│ │ │ ├── src
│ │ │ └── not-ok.ts
│ │ │ ├── test
│ │ │ └── ok.test-d.ts
│ │ │ ├── vite.config.ts
│ │ │ └── tsconfig.json
│ ├── tsconfig.json
│ ├── failing
│ │ ├── only.test-d.ts
│ │ ├── js-fail.test-d.js
│ │ └── expect-error.test-d.ts
│ ├── tsconfig.empty.json
│ ├── test-d
│ │ ├── js.test-d.js
│ │ └── nested-suite1.test-d.ts
│ ├── tsconfig.custom.json
│ └── test
│ │ ├── vitest.empty.config.ts
│ │ └── vitest.custom.config.ts
├── coverage-test
│ ├── fixtures
│ │ ├── setup.ts
│ │ ├── src
│ │ │ ├── load-outside-vite.cjs
│ │ │ ├── pre-transpiled
│ │ │ │ └── transpiled.d.ts
│ │ │ ├── json-data.json
│ │ │ ├── another-setup.ts
│ │ │ ├── Vue
│ │ │ │ ├── Counter
│ │ │ │ │ ├── index.ts
│ │ │ │ │ └── Counter.vue
│ │ │ │ └── vue.shim.d.ts
│ │ │ ├── import-meta-env.ts
│ │ │ ├── types-only.ts
│ │ │ ├── json-data-import.ts
│ │ │ ├── even.ts
│ │ │ ├── multi-suite.ts
│ │ │ ├── implicit-else.ts
│ │ │ ├── .should-be-excluded-from-coverage
│ │ │ │ └── excluded-from-coverage.ts
│ │ │ ├── file-to-change.ts
│ │ │ ├── test-that-looks-like-source-file.ts
│ │ │ ├── should-be-excluded-by-default.cts
│ │ │ └── math.ts
│ │ ├── test
│ │ │ ├── math.test.ts
│ │ │ ├── even.test.ts
│ │ │ ├── file-to-change.test.ts
│ │ │ ├── merge-fixture-1.test.ts
│ │ │ ├── merge-fixture-2.test.ts
│ │ │ ├── ignore-hints-fixture.test.ts
│ │ │ ├── import-attributes-fixture.test.ts
│ │ │ ├── multi-environment-fixture-ssr.test.ts
│ │ │ ├── multi-environment-fixture-web.test.ts
│ │ │ └── merge-fixture-3.test.ts
│ │ └── configs
│ │ │ └── vitest.config.ts
│ ├── tsconfig.json
│ └── test
│ │ └── multi-transform.test.ts
├── optimize-deps
│ ├── dep-url
│ │ ├── index.js
│ │ └── package.json
│ ├── package.json
│ └── test
│ │ └── web.test.ts
├── benchmark
│ ├── vitest.config.ts
│ ├── fixtures
│ │ ├── basic
│ │ │ └── vitest.config.ts
│ │ ├── compare
│ │ │ └── vitest.config.ts
│ │ ├── reporter
│ │ │ └── vitest.config.ts
│ │ └── sequential
│ │ │ ├── setup.ts
│ │ │ └── f2.bench.ts
│ ├── package.json
│ └── test
│ │ └── __snapshots__
│ │ └── reporter.test.ts.snap
├── snapshots
│ └── test
│ │ └── fixtures
│ │ ├── skip-test
│ │ ├── vitest.config.ts
│ │ └── __snapshots__
│ │ │ └── repro.test.ts.snap
│ │ ├── workspace
│ │ ├── packages
│ │ │ └── space
│ │ │ │ ├── vite.config.ts
│ │ │ │ └── test
│ │ │ │ ├── basic.test.ts
│ │ │ │ └── __snapshots__
│ │ │ │ └── basic.test.ts.snap
│ │ └── vitest.workspace.ts
│ │ ├── custom-snapshot-environment
│ │ ├── vitest.config.ts
│ │ └── test
│ │ │ └── snapshots.test.ts
│ │ └── custom-serializers
│ │ └── vitest.config.ts
├── test-utils
│ └── fixtures
│ │ └── math.ts
└── tsconfig.json
├── docs
├── public
│ ├── robots.txt
│ ├── og.png
│ ├── favicon.ico
│ ├── pwa-64x64.png
│ ├── maskable-icon.png
│ ├── og-original.png
│ ├── pwa-192x192.png
│ ├── pwa-512x512.png
│ ├── apple-touch-icon.png
│ ├── vitest-ui-coverage-dark.png
│ ├── vitest-ui-coverage-light.png
│ ├── vitest-ui-show-coverage-dark.png
│ └── vitest-ui-show-coverage-light.png
└── .vitepress
│ ├── theme
│ └── pwa.ts
│ └── components
│ ├── Version.vue
│ ├── NonProjectOption.vue
│ └── CourseLink.vue
├── examples
├── basic
│ ├── src
│ │ └── basic.ts
│ ├── README.md
│ ├── test
│ │ ├── __snapshots__
│ │ │ └── suite.test.ts.snap
│ │ └── suite.test.ts
│ ├── tsconfig.json
│ └── vite.config.ts
├── workspace
│ ├── packages
│ │ ├── client
│ │ │ ├── vitest.setup.ts
│ │ │ └── vitest.config.ts
│ │ └── server
│ │ │ └── src
│ │ │ └── index.ts
│ ├── vitest.workspace.ts
│ └── tsconfig.json
├── sveltekit
│ ├── static
│ │ └── favicon.png
│ ├── src
│ │ ├── routes
│ │ │ └── +page.svelte
│ │ ├── lib
│ │ │ ├── add.ts
│ │ │ └── add.test.ts
│ │ └── app.d.ts
│ ├── .gitignore
│ └── vite.config.ts
├── typecheck
│ └── test
│ │ ├── normal.test.ts
│ │ └── type.test-d.ts
├── preact
│ ├── src
│ │ ├── main.tsx
│ │ └── hooks
│ │ │ └── useCount.ts
│ ├── test
│ │ └── setup.ts
│ ├── tsconfig.node.json
│ └── index.html
├── react
│ ├── vitest.setup.ts
│ └── vitest.config.ts
├── fastify
│ └── src
│ │ ├── index.ts
│ │ └── app.ts
├── lit
│ └── tsconfig.json
└── solid
│ ├── test
│ └── __snapshots__
│ │ └── Hello.test.jsx.snap
│ └── components
│ └── Hello.jsx
├── .github
└── FUNDING.yml
├── .gitattributes
├── shims.d.ts
├── pnpm-workspace.yaml
├── FUNDING.json
├── .editorconfig
├── .tazerc.json
└── .npmrc
/packages/web-worker/index.d.ts:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/watch/fixtures/42.txt:
--------------------------------------------------------------------------------
1 | 42
2 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/empty.test.ts:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/core/src/file-txt.txt:
--------------------------------------------------------------------------------
1 | text
2 |
--------------------------------------------------------------------------------
/test/workspaces/.gitignore:
--------------------------------------------------------------------------------
1 | results.json
--------------------------------------------------------------------------------
/packages/vite-node/.gitignore:
--------------------------------------------------------------------------------
1 | *.d.ts
2 |
--------------------------------------------------------------------------------
/test/core/.env.local:
--------------------------------------------------------------------------------
1 | VITE_TEST_ENV=local
--------------------------------------------------------------------------------
/test/core/test/fixtures/snapshot-empty.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/reporters/.gitignore:
--------------------------------------------------------------------------------
1 | sonar-config.xml
--------------------------------------------------------------------------------
/test/reporters/fixtures/.gitignore:
--------------------------------------------------------------------------------
1 | html
2 |
--------------------------------------------------------------------------------
/test/vite-node/.env.local:
--------------------------------------------------------------------------------
1 | MY_TEST_ENV=hello
--------------------------------------------------------------------------------
/test/watch/.gitignore:
--------------------------------------------------------------------------------
1 | fixtures/test-results
--------------------------------------------------------------------------------
/test/cli/fixtures/setup-files/empty-setup.ts:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/core/test/fixtures/hi.txt:
--------------------------------------------------------------------------------
1 | Hello, World!
2 |
--------------------------------------------------------------------------------
/test/global-setup/index.html:
--------------------------------------------------------------------------------
1 | Hello Vitest
2 |
--------------------------------------------------------------------------------
/test/ui/.gitignore:
--------------------------------------------------------------------------------
1 | html
2 | test-results
3 |
--------------------------------------------------------------------------------
/test/workspaces-browser/.gitignore:
--------------------------------------------------------------------------------
1 | results.json
--------------------------------------------------------------------------------
/docs/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Allow: /
3 |
--------------------------------------------------------------------------------
/test/config/fixtures/pass-empty-files/empty.test.ts:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/core/src/esm/esm.js:
--------------------------------------------------------------------------------
1 | export const test = 1
2 |
--------------------------------------------------------------------------------
/test/core/src/mocks/dynamic-module.d.ts:
--------------------------------------------------------------------------------
1 | export {}
2 |
--------------------------------------------------------------------------------
/test/core/src/mocks/dynamic-module.js:
--------------------------------------------------------------------------------
1 | export {}
2 |
--------------------------------------------------------------------------------
/test/browser/injected-lib/index.js:
--------------------------------------------------------------------------------
1 | __injected.push(4)
2 |
--------------------------------------------------------------------------------
/test/cli/fixtures/vm-threads/src/external/assets/file1.png:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/cli/fixtures/vm-threads/src/external/assets/file2.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/cli/fixtures/vm-threads/src/external/assets/file3.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/core/src/file-sass.sass:
--------------------------------------------------------------------------------
1 | .red
2 | color: red;
3 |
--------------------------------------------------------------------------------
/test/core/src/mocks/moduleA.ts:
--------------------------------------------------------------------------------
1 | export const A = 'A'
2 |
--------------------------------------------------------------------------------
/test/core/src/submodule.ts:
--------------------------------------------------------------------------------
1 | export const two = 1 + 1
2 |
--------------------------------------------------------------------------------
/test/core/src/timeout.ts:
--------------------------------------------------------------------------------
1 | export const timeout = 100
2 |
--------------------------------------------------------------------------------
/packages/runner/types.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/types.js'
2 |
--------------------------------------------------------------------------------
/packages/runner/utils.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/utils.js'
2 |
--------------------------------------------------------------------------------
/packages/utils/diff.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/diff.js'
2 |
--------------------------------------------------------------------------------
/packages/utils/error.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/error.js'
2 |
--------------------------------------------------------------------------------
/packages/vite-node/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './types'
2 |
--------------------------------------------------------------------------------
/packages/vitest/index.d.cts:
--------------------------------------------------------------------------------
1 | export * from './dist/index.js'
2 |
--------------------------------------------------------------------------------
/packages/vitest/node.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/node.js'
2 |
--------------------------------------------------------------------------------
/packages/vitest/src/utils.ts:
--------------------------------------------------------------------------------
1 | export * from './utils/index'
2 |
--------------------------------------------------------------------------------
/packages/vitest/suite.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/suite.js'
2 |
--------------------------------------------------------------------------------
/packages/vitest/utils.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/utils.js'
2 |
--------------------------------------------------------------------------------
/test/browser/cjs-lib/lib.d.ts:
--------------------------------------------------------------------------------
1 | export function lib(): string
2 |
--------------------------------------------------------------------------------
/test/cli/fixtures/public-api/vitest.config.ts:
--------------------------------------------------------------------------------
1 | export default {}
--------------------------------------------------------------------------------
/test/config/fixtures/shard/vitest.config.js:
--------------------------------------------------------------------------------
1 | export default {}
--------------------------------------------------------------------------------
/test/core/src/aliased-mod.ts:
--------------------------------------------------------------------------------
1 | export const isAliased = true
2 |
--------------------------------------------------------------------------------
/test/core/src/cjs/array-cjs.js:
--------------------------------------------------------------------------------
1 | module.exports = [1, '2']
2 |
--------------------------------------------------------------------------------
/test/core/src/esm/internal-esm.mjs:
--------------------------------------------------------------------------------
1 | export * from 'tinyspy'
2 |
--------------------------------------------------------------------------------
/test/core/src/external/package.json:
--------------------------------------------------------------------------------
1 | { "type": "commonjs" }
2 |
--------------------------------------------------------------------------------
/test/core/src/external/pkg-node/ssr.js:
--------------------------------------------------------------------------------
1 | export default 'ssr'
2 |
--------------------------------------------------------------------------------
/test/core/src/external/pkg-node/web.js:
--------------------------------------------------------------------------------
1 | export default 'web'
2 |
--------------------------------------------------------------------------------
/test/core/src/file-css.css:
--------------------------------------------------------------------------------
1 | .red {
2 | color: red;
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/src/file-scss.scss:
--------------------------------------------------------------------------------
1 | .red {
2 | color: red;
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/src/global-mock.ts:
--------------------------------------------------------------------------------
1 | export const mocked = false
2 |
--------------------------------------------------------------------------------
/test/core/src/mocks/default.ts:
--------------------------------------------------------------------------------
1 | export default 'a default'
2 |
--------------------------------------------------------------------------------
/test/vite-node/src/deps.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | }
4 |
--------------------------------------------------------------------------------
/packages/snapshot/manager.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/manager.js'
2 |
--------------------------------------------------------------------------------
/packages/ui/client/composables/index.ts:
--------------------------------------------------------------------------------
1 | export * from './dark'
2 |
--------------------------------------------------------------------------------
/packages/utils/helpers.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/helpers.js'
2 |
--------------------------------------------------------------------------------
/packages/vitest/browser.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/browser.js'
2 |
--------------------------------------------------------------------------------
/packages/vitest/config.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/config.js'
2 |
--------------------------------------------------------------------------------
/packages/vitest/coverage.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/coverage.js'
2 |
--------------------------------------------------------------------------------
/packages/vitest/execute.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/execute.js'
2 |
--------------------------------------------------------------------------------
/packages/vitest/runners.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/runners.js'
2 |
--------------------------------------------------------------------------------
/packages/vitest/snapshot.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/snapshot.js'
2 |
--------------------------------------------------------------------------------
/packages/vitest/workers.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/workers.js'
2 |
--------------------------------------------------------------------------------
/packages/web-worker/pure.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/pure.js'
2 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/proxy-module.ts:
--------------------------------------------------------------------------------
1 | export * from 'vitest'
2 |
--------------------------------------------------------------------------------
/test/core/__mocks__/extension.js.ts:
--------------------------------------------------------------------------------
1 | export const mocked = true
2 |
--------------------------------------------------------------------------------
/test/core/__mocks__/vscode-mocks.ts:
--------------------------------------------------------------------------------
1 | export const folder = true
2 |
--------------------------------------------------------------------------------
/test/core/src/esm/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module"
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/src/external/pkg-browser/index.d.ts:
--------------------------------------------------------------------------------
1 | export default ''
2 |
--------------------------------------------------------------------------------
/test/core/src/external/pkg-browser/ssr.js:
--------------------------------------------------------------------------------
1 | export default 'ssr'
2 |
--------------------------------------------------------------------------------
/test/core/src/external/pkg-browser/web.js:
--------------------------------------------------------------------------------
1 | export default 'web'
2 |
--------------------------------------------------------------------------------
/test/core/src/external/pkg-node/index.d.ts:
--------------------------------------------------------------------------------
1 | export default ''
2 |
--------------------------------------------------------------------------------
/test/core/src/mocks/cyclic-deps/module-1.mjs:
--------------------------------------------------------------------------------
1 | import './module-2'
2 |
--------------------------------------------------------------------------------
/test/core/src/mocks/cyclic-deps/module-2.mjs:
--------------------------------------------------------------------------------
1 | import './module-3'
2 |
--------------------------------------------------------------------------------
/test/core/src/mocks/cyclic-deps/module-3.mjs:
--------------------------------------------------------------------------------
1 | import './module-4'
2 |
--------------------------------------------------------------------------------
/test/core/src/mocks/cyclic-deps/module-4.mjs:
--------------------------------------------------------------------------------
1 | import './module-1'
2 |
--------------------------------------------------------------------------------
/test/core/src/web-worker/selfWorkerDep.ts:
--------------------------------------------------------------------------------
1 | export default self
2 |
--------------------------------------------------------------------------------
/packages/utils/source-map.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/source-map.js'
2 |
--------------------------------------------------------------------------------
/packages/vitest/environments.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/environments'
2 |
--------------------------------------------------------------------------------
/packages/vitest/reporters.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/reporters.js'
2 |
--------------------------------------------------------------------------------
/packages/vitest/src/integrations/spy.ts:
--------------------------------------------------------------------------------
1 | export * from '@vitest/spy'
2 |
--------------------------------------------------------------------------------
/test/browser/test/__snapshots__/custom/my_snapshot:
--------------------------------------------------------------------------------
1 | my snapshot content
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/related/vitest.config.js:
--------------------------------------------------------------------------------
1 | export default {}
--------------------------------------------------------------------------------
/test/config/fixtures/base-path/src/index.ts:
--------------------------------------------------------------------------------
1 | export const foo = 'foo'
2 |
--------------------------------------------------------------------------------
/test/config/fixtures/workers-option/vitest.config.js:
--------------------------------------------------------------------------------
1 | export default {}
--------------------------------------------------------------------------------
/test/core/__mocks__/virtual-module.ts:
--------------------------------------------------------------------------------
1 | export const value = 'folder'
2 |
--------------------------------------------------------------------------------
/test/core/deps/dep2/index.js:
--------------------------------------------------------------------------------
1 | export { data } from '@vitest/test-dep1'
2 |
--------------------------------------------------------------------------------
/test/core/src/__mocks__/submodule.ts:
--------------------------------------------------------------------------------
1 | export const two = 1 + 1 + 1
2 |
--------------------------------------------------------------------------------
/test/core/src/mocks/squared.js:
--------------------------------------------------------------------------------
1 | export function squared() {
2 |
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/src/wasm/add.wasm:
--------------------------------------------------------------------------------
1 | asm ` add
2 | j
--------------------------------------------------------------------------------
/test/typescript/fixtures/source-error/src/not-ok.ts:
--------------------------------------------------------------------------------
1 | thisIsSourceError
2 |
--------------------------------------------------------------------------------
/examples/basic/src/basic.ts:
--------------------------------------------------------------------------------
1 | export const squared = (n: number) => n * n
2 |
--------------------------------------------------------------------------------
/packages/snapshot/environment.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/environment.js'
2 |
--------------------------------------------------------------------------------
/packages/ui/client/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/vitest/src/public/reporters.ts:
--------------------------------------------------------------------------------
1 | export * from '../node/reporters'
2 |
--------------------------------------------------------------------------------
/packages/vitest/vitest.mjs:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | import './dist/cli.js'
3 |
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/related/src/sourceA.ts:
--------------------------------------------------------------------------------
1 | export const A = 'A'
2 |
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/related/src/sourceB.ts:
--------------------------------------------------------------------------------
1 | export const B = 'B'
2 |
--------------------------------------------------------------------------------
/test/config/fixtures/vitest.config.js:
--------------------------------------------------------------------------------
1 | export default {
2 | test: {}
3 | }
--------------------------------------------------------------------------------
/test/core/projects/custom-lib/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module"
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/src/mocks/has space in path.ts:
--------------------------------------------------------------------------------
1 | export const thisIsOk = false
2 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/merge-reports/vitest.config.js:
--------------------------------------------------------------------------------
1 | export default {}
2 |
--------------------------------------------------------------------------------
/test/watch/fixtures/force-watch/trigger.js:
--------------------------------------------------------------------------------
1 | export const trigger = false
2 |
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/workspace/vitest.config.mjs:
--------------------------------------------------------------------------------
1 | export default {}
2 |
--------------------------------------------------------------------------------
/test/config/fixtures/conditions-subpackage/custom.js:
--------------------------------------------------------------------------------
1 | export default 'custom'
2 |
--------------------------------------------------------------------------------
/test/config/fixtures/workspace-flags/projects/vitest.config.js:
--------------------------------------------------------------------------------
1 | export default {}
--------------------------------------------------------------------------------
/test/config/fixtures/workspace-flags/vitest.workspace.js:
--------------------------------------------------------------------------------
1 | export default ['projects']
--------------------------------------------------------------------------------
/test/config/fixtures/workspace/nested/e2e.projects.js:
--------------------------------------------------------------------------------
1 | export default ['project-1']
--------------------------------------------------------------------------------
/test/core/src/cjs/module-cjs.ts:
--------------------------------------------------------------------------------
1 | module.exports.a = 1
2 | module.exports.b = 2
3 |
--------------------------------------------------------------------------------
/test/core/src/file-less.less:
--------------------------------------------------------------------------------
1 | @color: red;
2 |
3 | .red {
4 | color: @color;
5 | }
--------------------------------------------------------------------------------
/test/core/src/mockedA.ts:
--------------------------------------------------------------------------------
1 | export function mockedA() {
2 | return 'A'
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/src/mocks/moduleB.ts:
--------------------------------------------------------------------------------
1 | export const A = 'A'
2 | export const B = 'B'
3 |
--------------------------------------------------------------------------------
/test/core/src/wasm/wasm-bindgen/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module"
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/test/fixtures/snapshots/basic/output.css:
--------------------------------------------------------------------------------
1 | .name {
2 | color: red;
3 | }
--------------------------------------------------------------------------------
/test/reporters/fixtures/invalid-diff-config.ts:
--------------------------------------------------------------------------------
1 | export const diffOptions = {}
2 |
--------------------------------------------------------------------------------
/test/vite-node/src/circular1/a.ts:
--------------------------------------------------------------------------------
1 | export function a() {
2 | return 'A'
3 | }
4 |
--------------------------------------------------------------------------------
/test/vite-node/src/foo.js:
--------------------------------------------------------------------------------
1 | export function add(a, b) {
2 | return a + b
3 | }
4 |
--------------------------------------------------------------------------------
/packages/vite-node/vite-node.mjs:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | import('./dist/cli.mjs')
3 |
--------------------------------------------------------------------------------
/packages/vitest/src/utils/timers.ts:
--------------------------------------------------------------------------------
1 | export { getSafeTimers } from '@vitest/utils'
2 |
--------------------------------------------------------------------------------
/test/browser/cjs-lib/lib.mjs:
--------------------------------------------------------------------------------
1 | export function lib() {
2 | return 'original'
3 | }
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/workspace/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "commonjs"
3 | }
--------------------------------------------------------------------------------
/test/cli/fixtures/list/top-level-error.test.ts:
--------------------------------------------------------------------------------
1 | throw new Error('top level error')
2 |
--------------------------------------------------------------------------------
/test/cli/fixtures/restricted-fs/vitest.setup.js:
--------------------------------------------------------------------------------
1 | globalThis.SOME_TEST_VARIABLE = '3'
2 |
--------------------------------------------------------------------------------
/test/config/fixtures/conditions-subpackage/production.js:
--------------------------------------------------------------------------------
1 | export default 'production'
2 |
--------------------------------------------------------------------------------
/test/core/src/cjs/primitive-cjs.js:
--------------------------------------------------------------------------------
1 | module.exports = 'string'
2 | exports.a = 'a'
3 |
--------------------------------------------------------------------------------
/test/core/src/cjs/promise-export.js:
--------------------------------------------------------------------------------
1 | module.exports = Promise.resolve({ value: 42 })
2 |
--------------------------------------------------------------------------------
/test/core/src/module-esm.ts:
--------------------------------------------------------------------------------
1 | const c = 1
2 | export default c
3 | export const d = 2
4 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/setup.ts:
--------------------------------------------------------------------------------
1 | console.log('Running setup in fixtures root')
2 |
--------------------------------------------------------------------------------
/test/optimize-deps/dep-url/index.js:
--------------------------------------------------------------------------------
1 | export const importMetaUrl = import.meta.url
2 |
--------------------------------------------------------------------------------
/test/reporters/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json"
3 | }
4 |
--------------------------------------------------------------------------------
/test/workspaces-browser/space_browser_inline/test-alias-to.ts:
--------------------------------------------------------------------------------
1 | export default 'hello'
2 |
--------------------------------------------------------------------------------
/docs/public/og.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/docs/public/og.png
--------------------------------------------------------------------------------
/packages/vite-node/src/hmr/index.ts:
--------------------------------------------------------------------------------
1 | export * from './emitter'
2 | export * from './hmr'
3 |
--------------------------------------------------------------------------------
/packages/vitest/src/public/execute.ts:
--------------------------------------------------------------------------------
1 | export { VitestExecutor } from '../runtime/execute'
2 |
--------------------------------------------------------------------------------
/test/browser/custom-snapshot-env.ts:
--------------------------------------------------------------------------------
1 | throw new Error('This file should not be executed')
2 |
--------------------------------------------------------------------------------
/test/browser/fixtures/update-snapshot/__snapshots__/custom/my_snapshot:
--------------------------------------------------------------------------------
1 | my snapshot content
--------------------------------------------------------------------------------
/test/cli/fixtures/vm-threads/src/external/css/empty.css:
--------------------------------------------------------------------------------
1 | .test1 {
2 | color: red;
3 | }
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/vm-threads/src/external/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module"
3 | }
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/vm-threads/src/external/primitive-cjs.cjs:
--------------------------------------------------------------------------------
1 | module.exports = 'string'
2 |
--------------------------------------------------------------------------------
/test/config/fixtures/conditions-subpackage/development.js:
--------------------------------------------------------------------------------
1 | export default 'development'
2 |
--------------------------------------------------------------------------------
/test/config/fixtures/css/App.css:
--------------------------------------------------------------------------------
1 | .main {
2 | display: flex;
3 | width: 100px;
4 | }
5 |
--------------------------------------------------------------------------------
/test/core/__mocks__/timers.ts:
--------------------------------------------------------------------------------
1 | export default {
2 | clearInterval: () => 'foo',
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/src/in-source/index.ts:
--------------------------------------------------------------------------------
1 | export * from './add'
2 | export * from './fibonacci'
3 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/load-outside-vite.cjs:
--------------------------------------------------------------------------------
1 | module.exports = function noop() {}
2 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/pre-transpiled/transpiled.d.ts:
--------------------------------------------------------------------------------
1 | export * from './original'
2 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/json-fail-import.test.ts:
--------------------------------------------------------------------------------
1 | throw new Error('failed test suite')
2 |
--------------------------------------------------------------------------------
/examples/workspace/packages/client/vitest.setup.ts:
--------------------------------------------------------------------------------
1 | import '@testing-library/jest-dom/vitest'
2 |
--------------------------------------------------------------------------------
/packages/expect/index.d.ts:
--------------------------------------------------------------------------------
1 | import './dist/chai.cjs'
2 |
3 | export * from './dist/index.js'
4 |
--------------------------------------------------------------------------------
/packages/spy/README.md:
--------------------------------------------------------------------------------
1 | # @vitest/spy
2 |
3 | Lightweight Jest compatible spy implementation.
4 |
--------------------------------------------------------------------------------
/test/browser/fixtures/mocking/src/nested_child.ts:
--------------------------------------------------------------------------------
1 | export function child() {
2 | return true
3 | }
--------------------------------------------------------------------------------
/test/browser/src/__mocks__/_calculator.ts:
--------------------------------------------------------------------------------
1 | export function calculator() {
2 | return 4
3 | }
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/vm-threads/src/external/css/processed.css:
--------------------------------------------------------------------------------
1 | .test2 {
2 | color: green;
3 | }
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/vm-threads/src/external/package-null/package-null.js:
--------------------------------------------------------------------------------
1 | module.exports = 42
2 |
--------------------------------------------------------------------------------
/test/config/fixtures/conditions-pkg/index.js:
--------------------------------------------------------------------------------
1 | export { default as condition } from 'subpackage'
2 |
--------------------------------------------------------------------------------
/test/config/fixtures/project/vitest.workspace.ts:
--------------------------------------------------------------------------------
1 | export default [
2 | 'packages/*'
3 | ]
4 |
--------------------------------------------------------------------------------
/test/core/__mocks__/custom-lib.ts:
--------------------------------------------------------------------------------
1 | export default function () {
2 | return 'mocked'
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/src/mocks/external/default-cjs.cjs:
--------------------------------------------------------------------------------
1 | module.exports = require('./cjs-pseudoesm.cjs')
2 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/json-data.json:
--------------------------------------------------------------------------------
1 | {
2 | "foo": false,
3 | "bar": "baz"
4 | }
5 |
--------------------------------------------------------------------------------
/test/workspaces/space_1/.env.local:
--------------------------------------------------------------------------------
1 | VITE_MY_TEST_VARIABLE=local
2 | CUSTOM_MY_TEST_VARIABLE=custom
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [vitest-dev, sheremet-va, antfu, patak-dev]
2 | open_collective: vitest
3 |
--------------------------------------------------------------------------------
/docs/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/docs/public/favicon.ico
--------------------------------------------------------------------------------
/packages/vitest/src/node/cli.ts:
--------------------------------------------------------------------------------
1 | import { createCLI } from './cli/cac'
2 |
3 | createCLI().parse()
4 |
--------------------------------------------------------------------------------
/packages/vitest/src/public/coverage.ts:
--------------------------------------------------------------------------------
1 | export { BaseCoverageProvider } from '../utils/coverage'
2 |
--------------------------------------------------------------------------------
/test/browser/injected.ts:
--------------------------------------------------------------------------------
1 | // @ts-expect-error not typed global
2 | ;(__injected as string[]).push(3)
3 |
--------------------------------------------------------------------------------
/test/browser/src/actions.ts:
--------------------------------------------------------------------------------
1 | export function plus(a: number, b: number) {
2 | return a + b
3 | }
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/tty/example.ts:
--------------------------------------------------------------------------------
1 | export function getHelloWorld() {
2 | return 'Hello world'
3 | }
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/tty/math.ts:
--------------------------------------------------------------------------------
1 | export function sum(a: number, b: number) {
2 | return a + b
3 | }
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/conditions-subpackage/default.js:
--------------------------------------------------------------------------------
1 | throw new Error('Should not be imported')
2 |
--------------------------------------------------------------------------------
/test/core/projects/inline-lib/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module",
3 | "main": "index.js"
4 | }
5 |
--------------------------------------------------------------------------------
/test/core/src/cjs/bare-cjs.js:
--------------------------------------------------------------------------------
1 | module.exports = { c: 'c' }
2 | exports.a = 'a'
3 | exports.b = 'b'
4 |
--------------------------------------------------------------------------------
/test/core/src/env.ts:
--------------------------------------------------------------------------------
1 | export function getAuthToken() {
2 | return import.meta.env.AUTH_TOKEN
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/src/mocks/external/external.mjs:
--------------------------------------------------------------------------------
1 | import { vi } from 'vitest'
2 |
3 | vi.doMock('axios')
4 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/ok.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from "vitest"
2 |
3 | test("ok", () => {});
4 |
--------------------------------------------------------------------------------
/test/vite-node/src/watch/index.cjs:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line no-console
2 | console.log('test 1')
3 |
--------------------------------------------------------------------------------
/test/vite-node/src/watch/index.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line no-console
2 | console.log('test 1')
3 |
--------------------------------------------------------------------------------
/test/vite-node/src/watch/index.mjs:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line no-console
2 | console.log('test 1')
3 |
--------------------------------------------------------------------------------
/test/watch/fixtures/example.ts:
--------------------------------------------------------------------------------
1 | export function getHelloWorld() {
2 | return 'Hello world'
3 | }
4 |
--------------------------------------------------------------------------------
/test/watch/fixtures/math.ts:
--------------------------------------------------------------------------------
1 | export function sum(a: number, b: number) {
2 | return a + b
3 | }
4 |
--------------------------------------------------------------------------------
/test/workspaces/space_3/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vitest/space_3",
3 | "private": true
4 | }
5 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto eol=lf
2 |
3 | test/reporters/fixtures/indicator-position.test.js eol=crlf
4 |
--------------------------------------------------------------------------------
/docs/public/pwa-64x64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/docs/public/pwa-64x64.png
--------------------------------------------------------------------------------
/packages/ui/public/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/packages/ui/public/bg.png
--------------------------------------------------------------------------------
/packages/web-worker/src/index.ts:
--------------------------------------------------------------------------------
1 | import { defineWebWorkers } from './pure'
2 |
3 | defineWebWorkers()
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/restricted-fs/src/math.js:
--------------------------------------------------------------------------------
1 | export function multiply(a, b) {
2 | return a * b
3 | }
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/vm-threads/src/external/css/processed.module.css:
--------------------------------------------------------------------------------
1 | .test3 {
2 | color: yellow;
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/src/cjs/default-function.d.ts:
--------------------------------------------------------------------------------
1 | declare function format(): string
2 |
3 | export default format
4 |
--------------------------------------------------------------------------------
/test/core/src/mocks/external/default-function.cjs:
--------------------------------------------------------------------------------
1 | module.exports = function () {
2 | return true
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/src/web-worker/objectWorker.ts:
--------------------------------------------------------------------------------
1 | self.onmessage = (e) => {
2 | self.postMessage(e.data)
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/test/fixtures/increment.ts:
--------------------------------------------------------------------------------
1 | export function increment(num: number) {
2 | return num + 1
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/test/timers-node.test.ts:
--------------------------------------------------------------------------------
1 | // @vitest-environment node
2 |
3 | import './fixtures/timers.suite'
4 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/another-setup.ts:
--------------------------------------------------------------------------------
1 | console.log('Running another setup in fixtures src')
2 |
--------------------------------------------------------------------------------
/test/reporters/reportPkg/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "pkg-reporter",
3 | "main": "./index.js"
4 | }
5 |
--------------------------------------------------------------------------------
/test/ui/fixtures/coverage.ts:
--------------------------------------------------------------------------------
1 | export function multiply(n: number, m: number) {
2 | return n * m;
3 | }
4 |
--------------------------------------------------------------------------------
/docs/public/maskable-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/docs/public/maskable-icon.png
--------------------------------------------------------------------------------
/docs/public/og-original.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/docs/public/og-original.png
--------------------------------------------------------------------------------
/docs/public/pwa-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/docs/public/pwa-192x192.png
--------------------------------------------------------------------------------
/docs/public/pwa-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/docs/public/pwa-512x512.png
--------------------------------------------------------------------------------
/packages/coverage-istanbul/src/constants.ts:
--------------------------------------------------------------------------------
1 | export const COVERAGE_STORE_KEY: string = '__VITEST_COVERAGE__'
2 |
--------------------------------------------------------------------------------
/packages/vitest/src/node/reporters/html.ts:
--------------------------------------------------------------------------------
1 | export interface HTMLOptions {
2 | outputFile?: string
3 | }
4 |
--------------------------------------------------------------------------------
/packages/vitest/src/typecheck/expectTypeOf.ts:
--------------------------------------------------------------------------------
1 | export { expectTypeOf, type ExpectTypeOf } from 'expect-type'
2 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/no-assertions.test.ts:
--------------------------------------------------------------------------------
1 | import { it } from 'vitest'
2 |
3 | it('test without assertions')
--------------------------------------------------------------------------------
/test/cli/fixtures/setup-files/empty.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | test('empty', () => {})
4 |
--------------------------------------------------------------------------------
/test/core/__mocks__/axios.ts:
--------------------------------------------------------------------------------
1 | import { vi } from 'vitest'
2 |
3 | export default {
4 | get: vi.fn(),
5 | }
6 |
--------------------------------------------------------------------------------
/test/core/src/self/foo.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 |
3 | export function foo(): true {
4 | return true;
5 | }
--------------------------------------------------------------------------------
/test/core/src/web-worker/worker.ts:
--------------------------------------------------------------------------------
1 | self.onmessage = (e) => {
2 | self.postMessage(`${e.data} world`)
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/test/timers-jsdom.test.ts:
--------------------------------------------------------------------------------
1 | // @vitest-environment jsdom
2 |
3 | import './fixtures/timers.suite'
4 |
--------------------------------------------------------------------------------
/test/vite-node/src/cli-parse-args.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line no-console
2 | console.log(process.argv)
3 |
--------------------------------------------------------------------------------
/test/workspaces/space_shared/setup.node.ts:
--------------------------------------------------------------------------------
1 | Object.defineProperty(globalThis, 'testValue', { value: 'node' })
2 |
--------------------------------------------------------------------------------
/packages/browser/src/client/tester/jest-dom.ts:
--------------------------------------------------------------------------------
1 | export type { default } from '@testing-library/jest-dom/matchers'
2 |
--------------------------------------------------------------------------------
/packages/vitest/src/public/utils.ts:
--------------------------------------------------------------------------------
1 | export * from '@vitest/utils'
2 | export * from '@vitest/utils/source-map'
3 |
--------------------------------------------------------------------------------
/packages/ws-client/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "exclude": ["./dist"]
4 | }
5 |
--------------------------------------------------------------------------------
/test/browser/fixtures/mocking/src/actions.ts:
--------------------------------------------------------------------------------
1 | export function plus(a: number, b: number) {
2 | return a + b
3 | }
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/custom-pool/tests/custom-not-run.spec.ts:
--------------------------------------------------------------------------------
1 | throw new Error('this file is not actually running')
2 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/expect-soft.test.ts:
--------------------------------------------------------------------------------
1 | import { expect } from 'vitest'
2 |
3 | expect.soft(1 + 1).toEqual(3)
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/css/App.module.css:
--------------------------------------------------------------------------------
1 | .main {
2 | display: flex;
3 | }
4 |
5 | .module {
6 | width: 100px;
7 | }
--------------------------------------------------------------------------------
/test/config/fixtures/exclude/math.ts:
--------------------------------------------------------------------------------
1 | export function add(a: number, b: number): number {
2 | return a + b
3 | }
4 |
--------------------------------------------------------------------------------
/test/workspaces/space_3/src/multiply.ts:
--------------------------------------------------------------------------------
1 | export function multiple(a: number, b: number) {
2 | return a * b
3 | }
4 |
--------------------------------------------------------------------------------
/test/workspaces/space_shared/setup.jsdom.ts:
--------------------------------------------------------------------------------
1 | Object.defineProperty(globalThis, 'testValue', { value: 'jsdom' })
2 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/pwa.ts:
--------------------------------------------------------------------------------
1 | import { registerSW } from 'virtual:pwa-register'
2 |
3 | registerSW({ immediate: true })
4 |
--------------------------------------------------------------------------------
/docs/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/docs/public/apple-touch-icon.png
--------------------------------------------------------------------------------
/packages/ui/client/composables/dark.ts:
--------------------------------------------------------------------------------
1 | export const isDark = useDark()
2 | export const toggleDark = useToggle(isDark)
3 |
--------------------------------------------------------------------------------
/test/benchmark/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/browser/fixtures/mocking/src/__mocks__/mocks_calculator.ts:
--------------------------------------------------------------------------------
1 | export function calculator() {
2 | return 42
3 | }
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/stacktraces/frame.spec.imba:
--------------------------------------------------------------------------------
1 | describe "Test" do
2 | test("1+1") do
3 | expect(1+1).toBe 2
4 | ciyet.
--------------------------------------------------------------------------------
/test/config/fixtures/filters-slash/test/basic.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | test('example', () => {})
4 |
--------------------------------------------------------------------------------
/test/core/src/mocks/A.ts:
--------------------------------------------------------------------------------
1 | import { funcB } from './B.js'
2 |
3 | export function funcA() {
4 | return funcB
5 | }
6 |
--------------------------------------------------------------------------------
/test/core/src/mocks/B.ts:
--------------------------------------------------------------------------------
1 | import { funcA } from './A.js'
2 |
3 | export function funcB() {
4 | return funcA
5 | }
6 |
--------------------------------------------------------------------------------
/test/core/src/self/index.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 |
3 | export * from './foo';
4 | export * from './index'; // <-- wrong
--------------------------------------------------------------------------------
/test/core/test/setup.ts:
--------------------------------------------------------------------------------
1 | import { vi } from 'vitest'
2 |
3 | vi.mock('../src/global-mock', () => ({ mocked: true }))
4 |
--------------------------------------------------------------------------------
/test/vite-node/src/circular1/b.ts:
--------------------------------------------------------------------------------
1 | import { foo } from '.'
2 |
3 | export function b() {
4 | return `B${foo()}`
5 | }
6 |
--------------------------------------------------------------------------------
/test/vite-node/src/circular2/c.ts:
--------------------------------------------------------------------------------
1 | export const c = 'c'
2 |
3 | await new Promise(resolve => setTimeout(resolve, 10))
4 |
--------------------------------------------------------------------------------
/test/browser/cjs-lib/index.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | a: 'a',
3 | b: 'b',
4 | object: {
5 | h: 'h',
6 | },
7 | }
8 |
--------------------------------------------------------------------------------
/test/browser/custom-diff-config.ts:
--------------------------------------------------------------------------------
1 | export default {
2 | aAnnotation: 'Expected to be',
3 | bAnnotation: 'But got',
4 | }
5 |
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/workspace/vitest.workspace.js:
--------------------------------------------------------------------------------
1 | export default [
2 | "packages/*/vitest.config.js",
3 | ];
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/global-setup-fail/globalSetup/error.js:
--------------------------------------------------------------------------------
1 | export default function () {
2 | throw new Error('error')
3 | }
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/filters-slash/test/basic-foo/a.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | test('example', () => {})
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/filters-slash/test/basic/a.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | test('example', () => {})
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/filters-slash/test/foo-basic/a.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | test('example', () => {})
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/shard/test/1.test.js:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('1', () => expect(1).toBe(1))
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/shard/test/2.test.js:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('2', () => expect(1).toBe(1))
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/shard/test/3.test.js:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('3', () => expect(1).toBe(1))
4 |
--------------------------------------------------------------------------------
/test/core/src/mockedD.ts:
--------------------------------------------------------------------------------
1 | import { MockedC } from './mockedC'
2 |
3 | export default MockedC
4 | export * from './mockedC'
5 |
--------------------------------------------------------------------------------
/test/core/src/rely-on-hoisted.ts:
--------------------------------------------------------------------------------
1 | // @ts-expect-error not typed global
2 | export const value = globalThis.someGlobalValue
3 |
--------------------------------------------------------------------------------
/test/core/src/web-worker/selfWorker.ts:
--------------------------------------------------------------------------------
1 | import subSelf from './selfWorkerDep'
2 |
3 | self.postMessage(subSelf === self)
4 |
--------------------------------------------------------------------------------
/test/core/test/fixtures/hello-mock.ts:
--------------------------------------------------------------------------------
1 | export class HelloWorld {
2 | hello() {
3 | return 'Hello World!'
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/Vue/Counter/index.ts:
--------------------------------------------------------------------------------
1 | import CounterVue from './Counter.vue'
2 |
3 | export { CounterVue }
4 |
--------------------------------------------------------------------------------
/test/workspaces/.env.local:
--------------------------------------------------------------------------------
1 | VITE_MY_TEST_VARIABLE=core
2 | VITE_CORE_VARIABLE=core
3 | CUSTOM_ROOT=custom
4 | ROOT_VARIABLE=root
--------------------------------------------------------------------------------
/test/workspaces/cwdPlugin.d.ts:
--------------------------------------------------------------------------------
1 | import type { Plugin } from 'vite'
2 |
3 | export function cwdPlugin(name: string): Plugin
4 |
--------------------------------------------------------------------------------
/docs/public/vitest-ui-coverage-dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/docs/public/vitest-ui-coverage-dark.png
--------------------------------------------------------------------------------
/examples/sveltekit/static/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/examples/sveltekit/static/favicon.png
--------------------------------------------------------------------------------
/packages/vitest/importMeta.d.ts:
--------------------------------------------------------------------------------
1 | interface ImportMeta {
2 | url: string
3 | readonly vitest?: typeof import('vitest')
4 | }
5 |
--------------------------------------------------------------------------------
/shims.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/related/src/sourceC.ts:
--------------------------------------------------------------------------------
1 | // re-exporting for deep changed detection
2 | export { A } from './sourceA'
3 |
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/workspace/packages/packageA/index.js:
--------------------------------------------------------------------------------
1 | export default function getLetter() {
2 | return 'c';
3 | }
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/workspace/packages/packageB/index.js:
--------------------------------------------------------------------------------
1 | export default function getNumber() {
2 | return 3;
3 | }
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/stacktraces/foo.js:
--------------------------------------------------------------------------------
1 | export function add() {
2 | // eslint-disable-next-line no-undef
3 | return bar()
4 | }
5 |
--------------------------------------------------------------------------------
/test/core/src/mockedB.ts:
--------------------------------------------------------------------------------
1 | import { mockedA } from './mockedA'
2 |
3 | export function mockedB() {
4 | return mockedA()
5 | }
6 |
--------------------------------------------------------------------------------
/test/core/src/relative-import.ts:
--------------------------------------------------------------------------------
1 | export function dynamicRelativeImport(file: string) {
2 | return import(`./${file}.ts`)
3 | }
4 |
--------------------------------------------------------------------------------
/test/core/test/fixtures/mocked-dependency.ts:
--------------------------------------------------------------------------------
1 | export function helloWorld(): void {
2 | throw new Error('not implemented')
3 | }
4 |
--------------------------------------------------------------------------------
/test/vite-node/src/cli-print-env.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line no-console
2 | console.log(JSON.stringify(process.env, null, 2))
3 |
--------------------------------------------------------------------------------
/docs/public/vitest-ui-coverage-light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/docs/public/vitest-ui-coverage-light.png
--------------------------------------------------------------------------------
/packages/ui/reporter.d.ts:
--------------------------------------------------------------------------------
1 | import type { Reporter } from 'vitest'
2 |
3 | declare const reporter: Reporter
4 | export default reporter
5 |
--------------------------------------------------------------------------------
/packages/vitest/jsdom.d.ts:
--------------------------------------------------------------------------------
1 | import type { JSDOM } from 'jsdom'
2 |
3 | declare global {
4 | const jsdom: JSDOM
5 | }
6 | export {}
7 |
--------------------------------------------------------------------------------
/test/benchmark/fixtures/basic/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/benchmark/fixtures/compare/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/create-vitest/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/stacktraces/utils.ts:
--------------------------------------------------------------------------------
1 | export function add(...args: number[]) {
2 | return args.reduce((a, b) => a + b, 0)
3 | }
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/vitest.config.js:
--------------------------------------------------------------------------------
1 | // an empty config so the main one is not accidentaly inherited by the tests
2 | export default {}
3 |
--------------------------------------------------------------------------------
/test/config/fixtures/console/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/project/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/core/deps/dep1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vitest/test-dep1",
3 | "type": "module",
4 | "exports": "./esm/index.js"
5 | }
6 |
--------------------------------------------------------------------------------
/test/core/src/external/default-cjs.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | a: 'a',
3 | b: 'b',
4 | object: {
5 | h: 'h',
6 | },
7 | }
8 |
--------------------------------------------------------------------------------
/test/core/src/mocks/zustand-magic.ts:
--------------------------------------------------------------------------------
1 | import zustand from 'zustand'
2 |
3 | export function magic() {
4 | return zustand()
5 | }
6 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | })
5 |
--------------------------------------------------------------------------------
/docs/public/vitest-ui-show-coverage-dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/docs/public/vitest-ui-show-coverage-dark.png
--------------------------------------------------------------------------------
/pnpm-workspace.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | - docs
3 | - packages/*
4 | - examples/*
5 | - test/*
6 | - test/config/fixtures/conditions-pkg
7 |
--------------------------------------------------------------------------------
/test/benchmark/fixtures/reporter/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/inspect/math.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from "vitest";
2 |
3 | test("sum", () => {
4 | expect(1 + 1).toBe(2)
5 | })
--------------------------------------------------------------------------------
/test/config/fixtures/chai-config/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/conditions-test/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/console-color/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/filters-slash/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/test/vitest.config.js:
--------------------------------------------------------------------------------
1 | export default {
2 | test: {
3 | coverage: {
4 | reporter: [],
5 | },
6 | }
7 | }
--------------------------------------------------------------------------------
/test/core/src/cjs/class-cjs.js:
--------------------------------------------------------------------------------
1 | class Test {
2 | variable = 1
3 | }
4 |
5 | module.exports = new Test()
6 | module.exports.Test = Test
7 |
--------------------------------------------------------------------------------
/test/core/src/web-worker/eventListenerWorker.ts:
--------------------------------------------------------------------------------
1 | self.addEventListener('message', (e) => {
2 | self.postMessage(`${e.data} world`)
3 | })
4 |
--------------------------------------------------------------------------------
/test/core/test/fixtures/snapshots/basic/input.json:
--------------------------------------------------------------------------------
1 | [
2 | [
3 | ".name",
4 | {
5 | "color": "red"
6 | }
7 | ]
8 | ]
9 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/custom-diff-config.ts:
--------------------------------------------------------------------------------
1 | export default {
2 | aAnnotation: 'Expected to be',
3 | bAnnotation: 'But got',
4 | }
5 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/custom-error/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/FUNDING.json:
--------------------------------------------------------------------------------
1 | {
2 | "drips": {
3 | "ethereum": {
4 | "ownedBy": "0x929Eb10Cf1621b26199120a521C785F8271e0b78"
5 | }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/docs/public/vitest-ui-show-coverage-light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/docs/public/vitest-ui-show-coverage-light.png
--------------------------------------------------------------------------------
/examples/typecheck/test/normal.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('normal', () => {
4 | expect(1 + 1).toBe(2)
5 | })
6 |
--------------------------------------------------------------------------------
/packages/browser/context.js:
--------------------------------------------------------------------------------
1 | // empty file to not break bundling
2 | // Vitest resolves "@vitest/browser/context" as a virtual module instead
3 |
--------------------------------------------------------------------------------
/packages/ui/client/composables/explorer/index.ts:
--------------------------------------------------------------------------------
1 | import { ExplorerTree } from './tree'
2 |
3 | export const explorerTree = new ExplorerTree()
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/expect.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('hi', () => {
4 | expect(1 + 1).toEqual(3)
5 | })
6 |
--------------------------------------------------------------------------------
/test/cli/fixtures/plugin/basic.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from "vitest";
2 |
3 | test("basic", () => {
4 | expect(1).toBe(1);
5 | })
6 |
--------------------------------------------------------------------------------
/test/cli/fixtures/setup-files/console-setup.ts:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line no-console
2 | console.log('setup')
3 |
4 | console.error('setup')
5 |
--------------------------------------------------------------------------------
/test/config/fixtures/cache/basic.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from "vitest";
2 |
3 | test('', () => {
4 | expect(true).toBe(true)
5 | })
6 |
--------------------------------------------------------------------------------
/test/core/src/dynamic-import.ts:
--------------------------------------------------------------------------------
1 | export async function dynamicImport(name: string) {
2 | const pkg = await import(name)
3 | return pkg
4 | }
5 |
--------------------------------------------------------------------------------
/test/core/src/wasm/wasm-bindgen/index_bg.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/test/core/src/wasm/wasm-bindgen/index_bg.wasm
--------------------------------------------------------------------------------
/test/optimize-deps/dep-url/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vitest/test-deps-url",
3 | "type": "module",
4 | "exports": "./index.js"
5 | }
6 |
--------------------------------------------------------------------------------
/test/snapshots/test/fixtures/skip-test/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/vite-node/src/self-export.js:
--------------------------------------------------------------------------------
1 | const ansiEscapes = module.exports
2 | module.exports.default = ansiEscapes
3 | ansiEscapes.HelloWorld = 1
4 |
--------------------------------------------------------------------------------
/packages/expect/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "include": ["./src/**/*.ts"],
4 | "exclude": ["./dist"]
5 | }
6 |
--------------------------------------------------------------------------------
/packages/vite-node/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "include": ["./src/**/*.ts"],
4 | "exclude": ["./dist"]
5 | }
6 |
--------------------------------------------------------------------------------
/packages/vitest/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "include": ["src/**/*"],
4 | "exclude": ["**/dist/**"]
5 | }
6 |
--------------------------------------------------------------------------------
/test/browser/fixtures/server-url/basic.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from "vitest";
2 |
3 | test("basic", () => {
4 | expect(1).toBe(1);
5 | })
6 |
--------------------------------------------------------------------------------
/test/cli/fixtures/create-vitest/basic.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from "vitest";
2 |
3 | test("basic", () => {
4 | expect(1).toBe(1);
5 | })
6 |
--------------------------------------------------------------------------------
/test/cli/fixtures/vm-threads/src/external/export-default-cjs.js:
--------------------------------------------------------------------------------
1 | export * from './default-cjs.cjs'
2 | export { default } from './default-cjs.cjs'
3 |
--------------------------------------------------------------------------------
/test/cli/fixtures/ws-server-url/basic.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from "vitest";
2 |
3 | test("basic", () => {
4 | expect(1).toBe(1);
5 | })
6 |
--------------------------------------------------------------------------------
/test/config/fixtures/mode/example.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('should pass', () => {
4 | expect(1).toBe(1)
5 | })
6 |
--------------------------------------------------------------------------------
/test/config/fixtures/no-exec-args-fixtures/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/better-testsuite-name/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/suite-hook-failure/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/with-syntax-error.test.js:
--------------------------------------------------------------------------------
1 | // NOTE: This file is intentionally not valid JavaScript.
2 |
3 | it('should fail', () => {
4 | )
5 |
--------------------------------------------------------------------------------
/test/browser/fixtures/mocking/src/nested_parent.ts:
--------------------------------------------------------------------------------
1 | import { child } from './nested_child'
2 |
3 | export function parent() {
4 | return child()
5 | }
6 |
--------------------------------------------------------------------------------
/test/browser/test/__snapshots__/snapshot.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`snapshot 1`] = `1`;
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/expect-unreachable.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('', () => {
4 | expect.unreachable('hi')
5 | })
6 |
--------------------------------------------------------------------------------
/test/cli/fixtures/vm-threads/src/external/default-cjs.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | a: 'a',
3 | b: 'b',
4 | object: {
5 | h: 'h',
6 | },
7 | }
8 |
--------------------------------------------------------------------------------
/test/config/fixtures/allowed-exec-args-fixtures/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({})
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/console/basic.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | test('basic', () => {
4 | console.error("__test_console__");
5 | })
6 |
--------------------------------------------------------------------------------
/test/config/fixtures/test/example.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('it works', () => {
4 | expect(true).toBe(true)
5 | })
6 |
--------------------------------------------------------------------------------
/test/core/src/circularB.ts:
--------------------------------------------------------------------------------
1 | import { CalledB } from './circularA'
2 |
3 | export function circularB() {
4 | return CalledB.push(CalledB.length)
5 | }
6 |
--------------------------------------------------------------------------------
/examples/basic/README.md:
--------------------------------------------------------------------------------
1 | # Vitest Demo
2 |
3 | Run `npm test` and change a test or source code to see HMR in action!
4 |
5 | Learn more at https://vitest.dev
6 |
--------------------------------------------------------------------------------
/examples/workspace/vitest.workspace.ts:
--------------------------------------------------------------------------------
1 | import { defineWorkspace } from 'vitest/config'
2 |
3 | export default defineWorkspace([
4 | 'packages/*',
5 | ])
6 |
--------------------------------------------------------------------------------
/packages/snapshot/src/environment.ts:
--------------------------------------------------------------------------------
1 | export { NodeSnapshotEnvironment } from './env/node'
2 | export type { SnapshotEnvironment } from './types/environment'
3 |
--------------------------------------------------------------------------------
/packages/vitest/src/runtime/types/utils.ts:
--------------------------------------------------------------------------------
1 | export type SerializedSpec = [
2 | project: { name: string | undefined; root: string },
3 | file: string,
4 | ]
5 |
--------------------------------------------------------------------------------
/test/browser/test/another.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, it } from 'vitest'
2 |
3 | it('basic 3', async () => {
4 | expect(globalThis.window).toBeDefined()
5 | })
6 |
--------------------------------------------------------------------------------
/test/config/fixtures/project/packages/project_1/base.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from "vitest";
2 |
3 | test("", () => {
4 | expect(1).toBe(1);
5 | })
6 |
--------------------------------------------------------------------------------
/test/config/fixtures/project/packages/project_2/base.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from "vitest";
2 |
3 | test("", () => {
4 | expect(1).toBe(1);
5 | })
6 |
--------------------------------------------------------------------------------
/test/config/fixtures/project/packages/space_1/base.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from "vitest";
2 |
3 | test("", () => {
4 | expect(1).toBe(1);
5 | })
6 |
--------------------------------------------------------------------------------
/test/core/src/wasm/wasm-bindgen/README.md:
--------------------------------------------------------------------------------
1 | copied from https://github.com/jestjs/jest/tree/28d32c6a1e48f1e4c946a8e6adbe2ae9af4103e3/e2e/native-esm/wasm-bindgen
2 |
--------------------------------------------------------------------------------
/test/core/test/fixtures/snapshots/multiple/output.css:
--------------------------------------------------------------------------------
1 | .text-red {
2 | color: red;
3 | }
4 | .text-lg {
5 | font-size: 1.25rem;
6 | line-height: 1.75rem;
7 | }
--------------------------------------------------------------------------------
/test/coverage-test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "compilerOptions": {
4 | "experimentalDecorators": true
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/test/typescript/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "exclude": [
4 | "**/dist/**",
5 | "**/fixtures/**"
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/test/vite-node/src/circular2/a.ts:
--------------------------------------------------------------------------------
1 | import { c } from './reg'
2 |
3 | await new Promise(resolve => setTimeout(resolve, 10))
4 |
5 | export const a = `a${c}`
6 |
--------------------------------------------------------------------------------
/packages/ui/shim.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 |
--------------------------------------------------------------------------------
/packages/vitest/src/integrations/chai/chai-subset.d.ts:
--------------------------------------------------------------------------------
1 | declare module 'chai-subset' {
2 | const chaiSubset: Chai.ChaiPlugin
3 |
4 | export = chaiSubset
5 | }
6 |
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/workspace/packages/packageA/vitest.config.mjs:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({});
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/workspace/packages/packageB/vitest.config.mjs:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({});
4 |
--------------------------------------------------------------------------------
/test/cli/fixtures/global-setup-fail/example.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('example test', () => {
4 | expect(1 + 1).toBe(2)
5 | })
6 |
--------------------------------------------------------------------------------
/test/cli/fixtures/stacktraces/require-assertions.test.js:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | test('assertion is not called', () => {
4 | // no expect
5 | })
6 |
--------------------------------------------------------------------------------
/test/config/fixtures/filters/test/example.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('this will pass', () => {
4 | expect(1 + 1).toBe(2)
5 | })
6 |
--------------------------------------------------------------------------------
/test/config/fixtures/mixed-environments/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {},
5 | })
6 |
--------------------------------------------------------------------------------
/test/config/fixtures/workers-option/example.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('it works', () => {
4 | expect(true).toBe(true)
5 | })
6 |
--------------------------------------------------------------------------------
/test/config/fixtures/workspace-flags/projects/cli-config.test.ts:
--------------------------------------------------------------------------------
1 | import { it, expect } from 'vitest';
2 |
3 | it('math', () => {
4 | expect(1).toBe(1)
5 | })
6 |
--------------------------------------------------------------------------------
/test/core/src/mocks/export-default-circle-b.ts:
--------------------------------------------------------------------------------
1 | import b from './export-default-circle-index.js'
2 |
3 | export default function (): any {
4 | return b()
5 | }
6 |
--------------------------------------------------------------------------------
/test/core/src/mocks/export-default-circle-index.ts:
--------------------------------------------------------------------------------
1 | import b from './export-default-circle-b.js'
2 |
3 | export default function (): any {
4 | return b()
5 | }
6 |
--------------------------------------------------------------------------------
/test/core/src/wasm/wasm-bindgen-no-cyclic/index_bg.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zacharyvoase/vitest/main/test/core/src/wasm/wasm-bindgen-no-cyclic/index_bg.wasm
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/import-meta-env.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck -- untyped
2 | export function useImportEnv() {
3 | return import.meta.env.SOME_VARIABLE
4 | }
5 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/types-only.ts:
--------------------------------------------------------------------------------
1 | export type First = 'This' | 'file' | 'should'
2 |
3 | export type Second = 'be' | 'excluded' | 'from' | 'report'
4 |
--------------------------------------------------------------------------------
/examples/sveltekit/src/routes/+page.svelte:
--------------------------------------------------------------------------------
1 |
Welcome to SvelteKit
2 | Visit kit.svelte.dev to read the documentation
3 |
--------------------------------------------------------------------------------
/packages/vitest/src/public/runners.ts:
--------------------------------------------------------------------------------
1 | export { VitestTestRunner } from '../runtime/runners/test'
2 | export { NodeBenchmarkRunner } from '../runtime/runners/benchmark'
3 |
--------------------------------------------------------------------------------
/test/browser/fixtures/update-snapshot/__snapshots__/basic.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`basic 1`] = `1`;
4 |
--------------------------------------------------------------------------------
/test/browser/injected-lib/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vitest/injected-lib",
3 | "type": "module",
4 | "exports": {
5 | "default": "./index.js"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/test/cli/fixtures/stacktraces/setup.js:
--------------------------------------------------------------------------------
1 | import { expect, test, vi } from 'vitest'
2 |
3 | globalThis.vi = vi
4 | globalThis.test = test
5 | globalThis.expect = expect
6 |
--------------------------------------------------------------------------------
/test/cli/fixtures/vm-threads/src/external/export-nested-default-cjs.js:
--------------------------------------------------------------------------------
1 | export * from './nested-default-cjs.cjs'
2 | export { default } from './nested-default-cjs.cjs'
3 |
--------------------------------------------------------------------------------
/test/config/fixtures/exclude/string.ts:
--------------------------------------------------------------------------------
1 | export function capitalize(str: string): string {
2 | return str.slice(0, 1).toUpperCase() + str.slice(1).toLowerCase()
3 | }
4 |
--------------------------------------------------------------------------------
/test/config/fixtures/workspace/project-1/calculator-1.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, it } from 'vitest';
2 |
3 | it('1 + 1 = 2', () => {
4 | expect(1 + 1).toBe(2);
5 | })
6 |
--------------------------------------------------------------------------------
/test/config/fixtures/workspace/project-2/calculator-2.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, it } from 'vitest';
2 |
3 | it('2 + 2 = 4', () => {
4 | expect(2 + 2).toBe(4);
5 | })
6 |
--------------------------------------------------------------------------------
/test/workspaces/space_1/test/happy-dom.spec.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('window is defined', () => {
4 | expect(window).toBeDefined()
5 | })
6 |
--------------------------------------------------------------------------------
/test/cli/fixtures/stacktraces/error-in-deps.test.js:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 | import { add } from './foo'
3 |
4 | test('error in deps', () => {
5 | add()
6 | })
7 |
--------------------------------------------------------------------------------
/test/cli/fixtures/stacktraces/mocked-global.test.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-undef */
2 |
3 | vi.mock('./path')
4 |
5 | test('failed', () => {
6 | expect(1).toBe(2)
7 | })
8 |
--------------------------------------------------------------------------------
/test/core/projects/custom-lib/index.js:
--------------------------------------------------------------------------------
1 | export default function () {
2 | // module doesn't exist in Node.js ESM, but exists in vite-node
3 | return typeof module
4 | }
5 |
--------------------------------------------------------------------------------
/test/core/projects/inline-lib/index.js:
--------------------------------------------------------------------------------
1 | export default function () {
2 | // module doesn't exist in Node.js ESM, but exists in vite-node
3 | return typeof module
4 | }
5 |
--------------------------------------------------------------------------------
/test/core/src/cjs/default-function.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | function format() {
4 | return ''
5 | }
6 |
7 | module.exports = format
8 | module.exports.default = format
9 |
--------------------------------------------------------------------------------
/test/core/src/mocks/external/cjs-pseudoesm.cjs:
--------------------------------------------------------------------------------
1 | function fn() {}
2 |
3 | exports.fn = fn
4 | Object.defineProperty(exports, '__esModule', { value: true, enumerable: false })
5 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/json-data-import.ts:
--------------------------------------------------------------------------------
1 | import data from "./json-data.json" with { "type": "json" };
2 |
3 | export function getJSON() {
4 | return data
5 | };
6 |
--------------------------------------------------------------------------------
/test/typescript/fixtures/source-error/test/ok.test-d.ts:
--------------------------------------------------------------------------------
1 | import { expectTypeOf, test } from 'vitest'
2 |
3 | test('ok', () => {
4 | expectTypeOf(1).toEqualTypeOf(2)
5 | })
6 |
--------------------------------------------------------------------------------
/test/vite-node/src/hmr-script.js:
--------------------------------------------------------------------------------
1 | console.error('Hello!')
2 |
3 | if (import.meta.hot) {
4 | import.meta.hot.accept(() => {
5 | console.error('Accept')
6 | })
7 | }
8 |
--------------------------------------------------------------------------------
/examples/preact/src/main.tsx:
--------------------------------------------------------------------------------
1 | import { render } from 'preact'
2 | import App from './App.jsx'
3 | import './main.css'
4 |
5 | render(, document.getElementById('root')!)
6 |
--------------------------------------------------------------------------------
/test/cli/fixtures/dotted-files/.cache/projects/test/should-run.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('should run', () => {
4 | expect(1).toBe(1)
5 | })
6 |
--------------------------------------------------------------------------------
/test/cli/fixtures/tty/math.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | import { sum } from './math'
4 |
5 | test('sum', () => {
6 | expect(sum(1, 2)).toBe(3)
7 | })
8 |
--------------------------------------------------------------------------------
/test/config/fixtures/retry/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | retry: 3,
6 | },
7 | })
8 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/even.ts:
--------------------------------------------------------------------------------
1 | export function isEven(a: number) {
2 | return a % 2 === 0
3 | }
4 |
5 | export function isOdd(a: number) {
6 | return !isEven(a)
7 | }
--------------------------------------------------------------------------------
/test/reporters/fixtures/better-testsuite-name/vitest.workspace.ts:
--------------------------------------------------------------------------------
1 | import { defineWorkspace } from "vitest/config";
2 |
3 | export default defineWorkspace(['space-1', 'space-2'])
4 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/custom-diff-config.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('', () => {
4 | expect({ foo: 1 }).toMatchInlineSnapshot('xxx')
5 | })
6 |
--------------------------------------------------------------------------------
/test/snapshots/test/fixtures/workspace/packages/space/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineProject } from 'vitest/config'
2 |
3 | export default defineProject({
4 | test: {},
5 | })
6 |
--------------------------------------------------------------------------------
/test/snapshots/test/fixtures/workspace/vitest.workspace.ts:
--------------------------------------------------------------------------------
1 | import { defineWorkspace } from 'vitest/config'
2 |
3 | export default defineWorkspace([
4 | 'packages/*',
5 | ])
6 |
--------------------------------------------------------------------------------
/test/typescript/failing/only.test-d.ts:
--------------------------------------------------------------------------------
1 | import { expectTypeOf, test } from 'vitest'
2 |
3 | test.only('failing test', () => {
4 | expectTypeOf(1).toEqualTypeOf()
5 | })
6 |
--------------------------------------------------------------------------------
/test/watch/fixtures/math.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | import { sum } from './math'
4 |
5 | test('sum', () => {
6 | expect(sum(1, 2)).toBe(3)
7 | })
8 |
--------------------------------------------------------------------------------
/test/watch/fixtures/single-failed/failed.test.ts:
--------------------------------------------------------------------------------
1 | import { it } from 'vitest';
2 |
3 | it('fails', () => {
4 | console.log('log fail')
5 | throw new Error('failed')
6 | })
7 |
--------------------------------------------------------------------------------
/test/workspaces/space_2/test/node.spec.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('window is not defined', () => {
4 | expect(typeof window).toBe('undefined')
5 | })
6 |
--------------------------------------------------------------------------------
/test/browser/fixtures/mocking/src/mocks_factory.ts:
--------------------------------------------------------------------------------
1 | export function calculator(_action: string, _a: number, _b: number) {
2 | return _a + _b
3 | }
4 |
5 | export const mocked = false
6 |
--------------------------------------------------------------------------------
/test/cli/fixtures/console/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | printConsoleTrace: true,
6 | }
7 | })
--------------------------------------------------------------------------------
/test/config/fixtures/test/fake-timers.test.ts:
--------------------------------------------------------------------------------
1 | import { test, vi } from 'vitest'
2 |
3 | test('uses fake timers', () => {
4 | vi.useFakeTimers()
5 |
6 | vi.useRealTimers()
7 | })
8 |
--------------------------------------------------------------------------------
/test/core/__mocks__/fs.cjs:
--------------------------------------------------------------------------------
1 | // we can also use `import`, but then
2 | // every export should be explicitly defined
3 |
4 | const { fs } = require('memfs')
5 |
6 | module.exports = fs
7 |
--------------------------------------------------------------------------------
/test/core/src/circularA.ts:
--------------------------------------------------------------------------------
1 | import { circularB } from './circularB'
2 |
3 | export const CalledB: number[] = []
4 |
5 | export function circularA() {
6 | return circularB()
7 | }
8 |
--------------------------------------------------------------------------------
/test/core/test/__snapshots__/nested-suite.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`a > b > c > d > e > very deep > msg 1`] = `"hi"`;
4 |
--------------------------------------------------------------------------------
/test/core/test/moved-snapshot.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`snapshot is stored close to file 1`] = `"moved snapshot"`;
4 |
--------------------------------------------------------------------------------
/test/snapshots/test/fixtures/workspace/packages/space/test/basic.test.ts:
--------------------------------------------------------------------------------
1 | import { test, expect } from "vitest"
2 |
3 | test("basic", () => {
4 | expect(1).toMatchSnapshot()
5 | })
6 |
--------------------------------------------------------------------------------
/test/test-utils/fixtures/math.ts:
--------------------------------------------------------------------------------
1 | export function sum(a: number, b: number) {
2 | return a + b
3 | }
4 |
5 | export function multiply(a: number, b: number) {
6 | return a * b
7 | }
8 |
--------------------------------------------------------------------------------
/test/vite-node/src/circular2/reg.ts:
--------------------------------------------------------------------------------
1 | export { a } from './a'
2 |
3 | await new Promise(resolve => setTimeout(resolve, 20))
4 |
5 | export { b } from './b'
6 | export { c } from './c'
7 |
--------------------------------------------------------------------------------
/test/vite-node/src/testMod.ts:
--------------------------------------------------------------------------------
1 | export const a = 'hello testModule'
2 |
3 | // eslint-disable-next-line no-console
4 | console.log('[testModule.js] load!')
5 |
6 | import('./deps')
7 |
--------------------------------------------------------------------------------
/packages/vitest/src/typecheck/assertType.ts:
--------------------------------------------------------------------------------
1 | function noop() {}
2 |
3 | export interface AssertType {
4 | (value: T): void
5 | }
6 |
7 | export const assertType: AssertType = noop
8 |
--------------------------------------------------------------------------------
/packages/vitest/src/types/ui.ts:
--------------------------------------------------------------------------------
1 | export interface BrowserUI {
2 | setCurrentFileId: (fileId: string) => void
3 | setIframeViewport: (width: number, height: number) => Promise
4 | }
5 |
--------------------------------------------------------------------------------
/packages/web-worker/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "compilerOptions": {
4 | "lib": ["ESNext", "WebWorker"]
5 | },
6 | "exclude": ["./dist"]
7 | }
8 |
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/related/src/sourceD.ts:
--------------------------------------------------------------------------------
1 | // import and re-exporting for deep changed detection
2 | import { A as sourceA } from './sourceA'
3 |
4 | export const A = sourceA
5 |
--------------------------------------------------------------------------------
/test/cli/fixtures/stacktraces/mocked-imported.test.js:
--------------------------------------------------------------------------------
1 | import { expect, test, vi } from 'vitest'
2 |
3 | vi.mock('./path')
4 |
5 | test('failed', () => {
6 | expect(1).toBe(2)
7 | })
8 |
--------------------------------------------------------------------------------
/test/cli/fixtures/stacktraces/mocked-imported.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test, vi } from 'vitest'
2 |
3 | vi.mock('./path')
4 |
5 | test('failed', () => {
6 | expect(1).toBe(2)
7 | })
8 |
--------------------------------------------------------------------------------
/test/config/fixtures/console-color/basic.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | test("console color", () => {
4 | console.log(true) // node console highlights primitive
5 | })
6 |
--------------------------------------------------------------------------------
/test/config/fixtures/filters/test/config.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('this will pass', () => {
4 | expect('This test should be run').toBeTruthy()
5 | })
6 |
--------------------------------------------------------------------------------
/test/core/src/wasm/wasm-bindgen-no-cyclic/index.d.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable */
2 | /* eslint-disable */
3 | /**
4 | * @param {string} name
5 | */
6 | export function greet(name: string): void;
7 |
--------------------------------------------------------------------------------
/test/core/test/moved-snapshot.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('snapshot is stored close to file', () => {
4 | expect('moved snapshot').toMatchSnapshot()
5 | })
6 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/test/math.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 | import { sum } from '../src/math'
3 |
4 | test('sum', () => {
5 | expect(sum(1, 2)).toBe(3)
6 | })
7 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/better-testsuite-name/space-1/test/base.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, test } from "vitest";
2 |
3 | describe('space 1', () => {
4 | test('base', () => {})
5 | })
6 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/better-testsuite-name/space-2/test/base.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, test } from "vitest";
2 |
3 | describe('space 2', () => {
4 | test('base', () => {})
5 | })
6 |
--------------------------------------------------------------------------------
/test/snapshots/test/fixtures/workspace/packages/space/test/__snapshots__/basic.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`basic 1`] = `1`;
4 |
--------------------------------------------------------------------------------
/test/typescript/failing/js-fail.test-d.js:
--------------------------------------------------------------------------------
1 | // @ts-check
2 |
3 | import { expectTypeOf, test } from 'vitest'
4 |
5 | test('js test fails', () => {
6 | expectTypeOf(1).toBeArray()
7 | })
8 |
--------------------------------------------------------------------------------
/test/typescript/tsconfig.empty.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "include": [
4 | "src"
5 | ],
6 | "exclude": [
7 | "**/dist/**"
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/test/ui/fixtures/coverage.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, it } from 'vitest'
2 | import { multiply } from './coverage'
3 |
4 | it(multiply, () => {
5 | expect(multiply(2, 3)).toEqual(6)
6 | })
7 |
--------------------------------------------------------------------------------
/test/vite-node/src/self-export-example2.ts:
--------------------------------------------------------------------------------
1 | import ansiEscapes, { HelloWorld } from './self-export'
2 |
3 | // eslint-disable-next-line no-console
4 | console.log(ansiEscapes, HelloWorld)
5 |
--------------------------------------------------------------------------------
/test/watch/fixtures/single-failed/basic.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, it } from 'vitest';
2 |
3 | it('works correctly', () => {
4 | console.log('log basic')
5 | expect(1).toBe(1)
6 | })
7 |
--------------------------------------------------------------------------------
/test/workspaces-browser/space_1/test/node.spec.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('window is undefined', () => {
4 | expect(globalThis.window).toBeUndefined()
5 | })
6 |
--------------------------------------------------------------------------------
/test/workspaces-browser/space_1/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineProject } from 'vitest/config'
2 |
3 | export default defineProject({
4 | test: {
5 | name: 'space_1',
6 | },
7 | })
8 |
--------------------------------------------------------------------------------
/test/cli/fixtures/dotted-files/.cache/projects/test/.cache/should-not-run.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('should not run', () => {
4 | expect(1).toBe(2)
5 | })
6 |
--------------------------------------------------------------------------------
/test/core/src/external/pkg-node/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module",
3 | "exports": {
4 | "types": "./index.d.ts",
5 | "node": "./ssr.js",
6 | "browser": "./web.js"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/test/coverage-test/test/multi-transform.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from '../utils'
2 |
3 | test('files transformed with multiple transform modes work (#3251)', async () => {
4 | // TODO
5 | })
6 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/duration/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | slowTestThreshold: 290
6 | }
7 | })
8 |
--------------------------------------------------------------------------------
/test/typescript/test-d/js.test-d.js:
--------------------------------------------------------------------------------
1 | // @ts-check
2 |
3 | import { expectTypeOf, test } from 'vitest'
4 |
5 | test('js test also works', () => {
6 | expectTypeOf(1).toEqualTypeOf(2)
7 | })
8 |
--------------------------------------------------------------------------------
/test/vite-node/src/self-export.d.ts:
--------------------------------------------------------------------------------
1 | declare const ansiEscapes: {
2 | HelloWorld: number
3 | }
4 | export default ansiEscapes
5 |
6 | declare const HelloWorld: number
7 | export { HelloWorld }
8 |
--------------------------------------------------------------------------------
/test/workspaces-browser/space_browser/test/browser.spec.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('window is not defined', () => {
4 | expect(typeof window).toBe('object')
5 | })
6 |
--------------------------------------------------------------------------------
/test/workspaces/space_1/test/math.spec.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 | import { sum } from '../../src/math'
3 |
4 | test('3 + 3 = 6', () => {
5 | expect(sum(3, 3)).toBe(6)
6 | })
7 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/.dot-folder/dot-test.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('check that tests inside folder with . is run', () => {
4 | expect(true).toBe(false)
5 | })
6 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/primitive-error.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | test('primitive error thrown', () => {
4 | // eslint-disable-next-line no-throw-literal
5 | throw 42
6 | })
7 |
--------------------------------------------------------------------------------
/test/config/fixtures/filters/test/dont-run-this.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('this will fail', () => {
4 | expect('This test should not be run').toBeFalsy()
5 | })
6 |
--------------------------------------------------------------------------------
/test/core/src/external/pkg-browser/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module",
3 | "exports": {
4 | "types": "./index.d.ts",
5 | "browser": "./web.js",
6 | "node": "./ssr.js"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/test/core/src/read-hello-world.ts:
--------------------------------------------------------------------------------
1 | // hello-world.js
2 | import { readFileSync } from 'node:fs'
3 |
4 | export function readHelloWorld(path: string) {
5 | return readFileSync(path, 'utf-8')
6 | }
7 |
--------------------------------------------------------------------------------
/test/core/test/__snapshots__/suite.test.tsx.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`suite name > snapshot 1`] = `
4 | {
5 | "foo": "bar",
6 | }
7 | `;
8 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/multi-suite.ts:
--------------------------------------------------------------------------------
1 | export default {
2 | func1(data: any[]) {
3 | return data
4 | },
5 |
6 | func2(data: any[]) {
7 | return data
8 | },
9 | }
10 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/test/even.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 | import { isEven } from '../src/even'
3 |
4 | test('isEven', () => {
5 | expect(isEven(6)).toBe(true)
6 | })
7 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/examples/basic/test/__snapshots__/suite.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`suite name > snapshot 1`] = `
4 | {
5 | "foo": "bar",
6 | }
7 | `;
8 |
--------------------------------------------------------------------------------
/examples/preact/test/setup.ts:
--------------------------------------------------------------------------------
1 | import { afterEach } from 'vitest'
2 | import { cleanup } from '@testing-library/preact'
3 | import '@testing-library/jest-dom/vitest'
4 |
5 | afterEach(() => cleanup())
6 |
--------------------------------------------------------------------------------
/packages/browser/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "compilerOptions": {
4 | "types": ["node", "vite/client"]
5 | },
6 | "exclude": ["dist", "node_modules"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/runner/README.md:
--------------------------------------------------------------------------------
1 | # @vitest/runner
2 |
3 | Vitest mechanism to collect and run tasks.
4 |
5 | [GitHub](https://github.com/vitest-dev/vitest) | [Documentation](https://vitest.dev/advanced/runner)
6 |
--------------------------------------------------------------------------------
/test/browser/src/createNode.ts:
--------------------------------------------------------------------------------
1 | export function createNode() {
2 | const div = document.createElement('div')
3 | div.className = 'node'
4 | div.textContent = 'Hello World!'
5 | return div
6 | }
7 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/each-timeout.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | test.each([1])('test each timeout', async () => {
4 | await new Promise(resolve => setTimeout(resolve, 20))
5 | }, 10)
6 |
--------------------------------------------------------------------------------
/test/core/__mocks__/fs/promises.cjs:
--------------------------------------------------------------------------------
1 | // we can also use `import`, but then
2 | // every export should be explicitly defined
3 |
4 | const { fs } = require('memfs')
5 |
6 | module.exports = fs.promises
7 |
--------------------------------------------------------------------------------
/test/core/src/wasm/wasm-bindgen-no-cyclic/index.js:
--------------------------------------------------------------------------------
1 | import * as wasm from "./index_bg.wasm";
2 | import { __wbg_set_wasm } from "./index_bg.js";
3 | __wbg_set_wasm(wasm);
4 | export * from "./index_bg.js";
5 |
--------------------------------------------------------------------------------
/test/core/test/stubbed-process.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, it, vi } from 'vitest'
2 |
3 | vi.stubGlobal('process', { badMock: true })
4 |
5 | it('should not hang', () => {
6 | expect(1).toBe(1)
7 | })
8 |
--------------------------------------------------------------------------------
/test/core/vitest-environment-custom/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vitest-environment-custom",
3 | "private": true,
4 | "exports": {
5 | ".": "./index.ts"
6 | },
7 | "main": "index.ts"
8 | }
9 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/implicit-else.ts:
--------------------------------------------------------------------------------
1 | export function implicitElse(condition: boolean) {
2 | let a = 1
3 |
4 | if (condition) {
5 | a = 2
6 | }
7 |
8 | return a
9 | }
10 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/test/file-to-change.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 | import { run } from '../src/file-to-change'
3 |
4 | test('test case for changed file', () => {
5 | run()
6 | })
7 |
--------------------------------------------------------------------------------
/test/typescript/tsconfig.custom.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "include": [
4 | "**/fail.test-d.ts"
5 | ],
6 | "exclude": [
7 | "**/dist/**"
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/test/workspaces-browser/space_1/test/math.spec.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 | import { sum } from '../../src/math'
3 |
4 | test('3 + 3 = 6', () => {
5 | expect(sum(3, 3)).toBe(6)
6 | })
7 |
--------------------------------------------------------------------------------
/examples/sveltekit/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /build
4 | /.svelte-kit
5 | /package
6 | .env
7 | .env.*
8 | !.env.example
9 | vite.config.js.timestamp-*
10 | vite.config.ts.timestamp-*
11 |
--------------------------------------------------------------------------------
/examples/sveltekit/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { sveltekit } from '@sveltejs/kit/vite'
2 | import { defineConfig } from 'vitest/config'
3 |
4 | export default defineConfig({
5 | plugins: [sveltekit()],
6 | })
7 |
--------------------------------------------------------------------------------
/examples/typecheck/test/type.test-d.ts:
--------------------------------------------------------------------------------
1 | import { expect, expectTypeOf, test } from 'vitest'
2 |
3 | test('type', () => {
4 | expectTypeOf(1).toEqualTypeOf(2)
5 | expect(1).toBe(2) // not executed
6 | })
7 |
--------------------------------------------------------------------------------
/test/core/deps/dep2/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vitest/test-dep2",
3 | "type": "module",
4 | "exports": "./index.js",
5 | "dependencies": {
6 | "@vitest/test-dep1": "file:../dep1"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/test/core/test/self.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, it } from 'vitest'
2 | import { foo } from '../src/self'
3 |
4 | // #1220 self export module
5 | it('self export', () => {
6 | expect(foo()).toBe(true)
7 | })
8 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/.should-be-excluded-from-coverage/excluded-from-coverage.ts:
--------------------------------------------------------------------------------
1 | // This file should be excluded from coverage report
2 |
3 | export function uncoveredFile() {
4 | return 0
5 | }
6 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/file-to-change.ts:
--------------------------------------------------------------------------------
1 | export function run() {
2 | return 'This file will be modified by test cases'
3 | }
4 |
5 | export function uncoveredFunction() {
6 | return 1 + 2
7 | }
8 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/test/merge-fixture-1.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 | import { sum } from '../src/math'
3 |
4 | test('cover sum', () => {
5 | expect(sum(1, 2)).toBe(3)
6 | })
7 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/error-to-json.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from "vitest";
2 |
3 | test("error serialization with toJSON", () => {
4 | throw Object.assign(new Error("hello"), { date: new Date(0) })
5 | })
6 |
--------------------------------------------------------------------------------
/test/workspaces/space_3/localSetup.ts:
--------------------------------------------------------------------------------
1 | import type { GlobalSetupContext } from 'vitest/node'
2 |
3 | export function setup({ provide }: GlobalSetupContext) {
4 | provide('globalSetupOverriden', true)
5 | }
6 |
--------------------------------------------------------------------------------
/.tazerc.json:
--------------------------------------------------------------------------------
1 | {
2 | "exclude": [
3 | "vue",
4 | "pretty-format"
5 | ],
6 | "packageMode": {
7 | "vue": "minor",
8 | "codemirror": "minor",
9 | "rollup": "minor"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/examples/react/vitest.setup.ts:
--------------------------------------------------------------------------------
1 | import '@testing-library/jest-dom/vitest'
2 | import { cleanup } from '@testing-library/react'
3 | import { afterEach } from 'vitest'
4 |
5 | afterEach(() => {
6 | cleanup()
7 | })
8 |
--------------------------------------------------------------------------------
/test/browser/fixtures/mocking/not-mocked-nested.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 | import { parent } from './src/nested_parent'
3 |
4 | test('adds', () => {
5 | expect(parent()).toBe(true)
6 | })
7 |
--------------------------------------------------------------------------------
/test/cli/fixtures/inspect/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | include: ['./**.test.ts'],
6 | watch: false,
7 | },
8 | })
9 |
--------------------------------------------------------------------------------
/test/config/fixtures/exclude/math.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | import { add } from './math'
4 |
5 | test('should add two numbers correctly', () => {
6 | expect(add(1, 2)).toBe(3)
7 | })
8 |
--------------------------------------------------------------------------------
/test/core/test/env-glob.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('default', () => {
4 | expect(typeof window).toBe('undefined')
5 | expect(expect.getState().environment).toBe('node')
6 | })
7 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/configs/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import vue from "@vitejs/plugin-vue";
2 | import { defineConfig } from 'vitest/config'
3 |
4 | export default defineConfig({
5 | plugins: [vue()],
6 | })
7 |
--------------------------------------------------------------------------------
/test/cli/fixtures/custom-pool/tests/custom-run.threads.spec.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('correctly runs threads test while there is a custom pool', () => {
4 | expect(1 + 1).toBe(2)
5 | })
6 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/test-extend/fixture-rest-params.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | test.extend({
4 | // eslint-disable-next-line unused-imports/no-unused-vars
5 | a: async (...rest) => {},
6 | })
7 |
--------------------------------------------------------------------------------
/test/cli/fixtures/list/math.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, it } from 'vitest'
2 |
3 | it('1 plus 1', () => {
4 | expect(1 + 1).toBe(2)
5 | })
6 |
7 | it('failing test', () => {
8 | expect(1 + 1).toBe(3)
9 | })
10 |
--------------------------------------------------------------------------------
/test/config/fixtures/exclude/vitest.exclude.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | include: ['fixtures/exclude/*.test.ts'],
6 | },
7 | })
8 |
--------------------------------------------------------------------------------
/test/core/src/cjs/nested-default-cjs.js:
--------------------------------------------------------------------------------
1 | exports.default = {
2 | a: 'a',
3 | b: 'b',
4 | object: {
5 | h: 'h',
6 | },
7 | }
8 | Object.defineProperty(exports, '__esModule', { value: true, enumerable: false })
9 |
--------------------------------------------------------------------------------
/test/reporters/without-custom-reporter.vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | include: ['tests/reporters.spec.ts'],
6 | },
7 | })
8 |
--------------------------------------------------------------------------------
/test/vite-node/src/circular2/b.ts:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line unused-imports/no-unused-imports
2 | import { a } from './a'
3 |
4 | await new Promise(resolve => setTimeout(resolve, 10))
5 |
6 | export const b = 'b'
7 |
--------------------------------------------------------------------------------
/test/workspaces/coverage-report-tests/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | include: ['./check-coverage.test.ts'],
6 | },
7 | })
8 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | ignore-workspace-root-check=true
2 | strict-peer-dependencies=false
3 | provenance=true
4 | shell-emulator=true
5 | registry=https://registry.npmjs.org/
6 | VITE_NODE_DEPS_MODULE_DIRECTORIES=/node_modules/,/packages/
7 |
--------------------------------------------------------------------------------
/packages/browser/src/client/ui.ts:
--------------------------------------------------------------------------------
1 | import type { BrowserUI } from 'vitest'
2 |
3 | export function getUiAPI(): BrowserUI | undefined {
4 | // @ts-expect-error not typed global
5 | return window.__vitest_ui_api__
6 | }
7 |
--------------------------------------------------------------------------------
/packages/web-worker/src/types.ts:
--------------------------------------------------------------------------------
1 | export type Procedure = (...args: any[]) => void
2 | export type CloneOption = 'native' | 'ponyfill' | 'none'
3 |
4 | export interface DefineWorkerOptions {
5 | clone: CloneOption
6 | }
7 |
--------------------------------------------------------------------------------
/test/browser/fixtures/mocking/not-mocked.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 | import { calculator } from './src/calculator'
3 |
4 | test('adds', () => {
5 | expect(calculator('plus', 1, 2)).toBe(3)
6 | })
7 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/test-extend/fixture-rest-props.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | test.extend({
4 | // eslint-disable-next-line unused-imports/no-unused-vars
5 | a: async ({ ...rest }) => {},
6 | })
7 |
--------------------------------------------------------------------------------
/test/cli/fixtures/list/fail.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | include: ['top-level-error.test.ts', 'describe-error.test.ts'],
6 | },
7 | })
8 |
--------------------------------------------------------------------------------
/test/cli/fixtures/tty/example.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | import { getHelloWorld } from './example'
4 |
5 | test('getHello', async () => {
6 | expect(getHelloWorld()).toBe('Hello world')
7 | })
8 |
--------------------------------------------------------------------------------
/test/core/src/external/nested-default-cjs.js:
--------------------------------------------------------------------------------
1 | exports.default = {
2 | a: 'a',
3 | b: 'b',
4 | object: {
5 | h: 'h',
6 | },
7 | }
8 | Object.defineProperty(exports, '__esModule', { value: true, enumerable: false })
9 |
--------------------------------------------------------------------------------
/test/core/src/mocks/main.js:
--------------------------------------------------------------------------------
1 | import { funcA } from './A'
2 | import { funcB } from './B'
3 |
4 | export function main() {
5 | return funcA()
6 | }
7 |
8 | export function mainB() {
9 | return funcB()
10 | }
11 |
--------------------------------------------------------------------------------
/test/core/test/__snapshots__/snapshot-concurrent-sync.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`concurrent suite > snapshot 1`] = `
4 | {
5 | "foo": "bar",
6 | }
7 | `;
8 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/test/merge-fixture-2.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 | import { multiply } from '../src/math'
3 |
4 | test('cover multiply', () => {
5 | expect(multiply(3, 2)).toBe(6)
6 | })
7 |
--------------------------------------------------------------------------------
/test/ui/fixtures/task-name.test.ts:
--------------------------------------------------------------------------------
1 | import { it, expect} from "vitest"
2 |
3 | it('', () => {
4 | expect(true).toBe(true)
5 | })
6 |
7 | it('<>\'"', () => {
8 | expect(true).toBe(true)
9 | })
10 |
--------------------------------------------------------------------------------
/packages/coverage-v8/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "compilerOptions": {
4 | "moduleResolution": "Bundler"
5 | },
6 | "include": ["./src/**/*.ts"],
7 | "exclude": ["./dist"]
8 | }
9 |
--------------------------------------------------------------------------------
/test/benchmark/fixtures/sequential/setup.ts:
--------------------------------------------------------------------------------
1 | import fs from "node:fs";
2 | import { testLogFile } from "./helper";
3 |
4 | export default async function setup() {
5 | await fs.promises.rm(testLogFile, { force: true });
6 | }
7 |
--------------------------------------------------------------------------------
/test/browser/fixtures/mocking-watch/2_not-mocked-import.test.ts:
--------------------------------------------------------------------------------
1 | import { lib } from '@vitest/cjs-lib/lib'
2 | import { test, expect } from 'vitest'
3 |
4 | test('not mocked', () => {
5 | expect(lib()).toBe('original')
6 | })
7 |
--------------------------------------------------------------------------------
/test/browser/src/error.ts:
--------------------------------------------------------------------------------
1 | interface _SomeType {
2 | _unused: string
3 | }
4 |
5 | // this should affect the line number
6 |
7 | export function throwError(_opts?: _SomeType) {
8 | throw new Error('error')
9 | }
10 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/test-extend/fixture-without-destructuring.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | test.extend({
4 | // eslint-disable-next-line unused-imports/no-unused-vars
5 | a: async (context) => {},
6 | })
7 |
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/related/not-related.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 | import { B } from './src/sourceB'
3 |
4 | test('shouldn\'t run', () => {
5 | expect(B).toBe('B')
6 | expect.fail()
7 | })
8 |
--------------------------------------------------------------------------------
/docs/.vitepress/components/Version.vue:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 | +
8 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/coverage-istanbul/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "compilerOptions": {
4 | "moduleResolution": "Bundler"
5 | },
6 | "include": ["./src/**/*.ts"],
7 | "exclude": ["./dist"]
8 | }
9 |
--------------------------------------------------------------------------------
/packages/vitest/src/public/snapshot.ts:
--------------------------------------------------------------------------------
1 | export type { SnapshotEnvironment } from '@vitest/snapshot/environment'
2 | export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from '../integrations/snapshot/environments/node'
3 |
--------------------------------------------------------------------------------
/test/browser/test/failing.snaphot.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('file snapshot', async () => {
4 | await expect('inaccessible snapshot content')
5 | .toMatchFileSnapshot('/inaccesible/path')
6 | })
7 |
--------------------------------------------------------------------------------
/test/browser/vitest.config-basepath.mts:
--------------------------------------------------------------------------------
1 | import { defineConfig, mergeConfig } from 'vitest/config'
2 | import baseConfig from './vitest.config.mjs'
3 |
4 | export default mergeConfig(baseConfig, defineConfig({ base: '/fix-4686' }))
5 |
--------------------------------------------------------------------------------
/test/core/src/web-worker/worker-globals.ts:
--------------------------------------------------------------------------------
1 | self.onmessage = () => {
2 | self.postMessage({
3 | crypto: !!self.crypto,
4 | caches: !!self.caches,
5 | location: !!self.location,
6 | origin: self.origin,
7 | })
8 | }
9 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/console-simple.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, expect, test } from 'vitest'
2 |
3 | test('test', () => {
4 | console.log('__test_stdout__')
5 | console.error('__test_stderr__')
6 | expect(0).toBe(0)
7 | })
8 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/some-failing.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('2 + 3 = 5', () => {
4 | expect(2 + 3).toBe(5)
5 | })
6 |
7 | test('3 + 3 = 7', () => {
8 | expect(3 + 3).toBe(7)
9 | })
10 |
--------------------------------------------------------------------------------
/test/reporters/reportPkg/index.js:
--------------------------------------------------------------------------------
1 | export default class PackageReporter {
2 | onInit(ctx) {
3 | this.ctx = ctx
4 | }
5 |
6 | onFinished() {
7 | this.ctx.logger.log('hello from package reporter')
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/test/reporters/src/custom-reporter.js:
--------------------------------------------------------------------------------
1 | export default class TestReporter {
2 | onInit(ctx) {
3 | this.ctx = ctx
4 | }
5 |
6 | onFinished() {
7 | this.ctx.logger.log('hello from custom reporter')
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/test/typescript/fixtures/source-error/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | typecheck: {
6 | enabled: true,
7 | },
8 | },
9 | })
10 |
--------------------------------------------------------------------------------
/examples/sveltekit/src/lib/add.ts:
--------------------------------------------------------------------------------
1 | import { dev } from '$app/environment'
2 |
3 | export function add(a: number, b: number) {
4 | if (dev) {
5 | console.warn(`Adding ${a} and ${b}`)
6 | }
7 |
8 | return a + b
9 | }
10 |
--------------------------------------------------------------------------------
/examples/workspace/packages/client/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | environment: 'jsdom',
6 | setupFiles: './vitest.setup.ts',
7 | },
8 | })
9 |
--------------------------------------------------------------------------------
/test/browser/test/server-headers.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, it } from 'vitest'
2 |
3 | it('server.headers', async () => {
4 | const res = await fetch('/')
5 | expect(res.ok)
6 | expect(res.headers.get('x-custom')).toBe('hello')
7 | })
8 |
--------------------------------------------------------------------------------
/test/browser/test/utils.test.ts:
--------------------------------------------------------------------------------
1 | import { inspect } from 'vitest/utils'
2 | import { expect, it } from 'vitest'
3 |
4 | it('utils package correctly uses loupe', async () => {
5 | expect(inspect({ test: 1 })).toBe('{ test: 1 }')
6 | })
7 |
--------------------------------------------------------------------------------
/test/config/fixtures/conditions-pkg/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "conditions",
3 | "private": true,
4 | "type": "module",
5 | "main": "index.js",
6 | "dependencies": {
7 | "subpackage": "file:../conditions-subpackage"
8 | }
9 | }
--------------------------------------------------------------------------------
/test/core/test/env-glob-dom/env-glob.spec.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('glob on folder', () => {
4 | expect(typeof window).not.toBe('undefined')
5 | expect(expect.getState().environment).toBe('jsdom')
6 | })
7 |
--------------------------------------------------------------------------------
/test/core/test/env-glob.dom.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('glob on extension', () => {
4 | expect(typeof window).not.toBe('undefined')
5 | expect(expect.getState().environment).toBe('happy-dom')
6 | })
7 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/default/MockReporter.ts:
--------------------------------------------------------------------------------
1 | import { DefaultReporter } from '../../../../packages/vitest/src/node/reporters/default'
2 |
3 | export default class MockDefaultReporter extends DefaultReporter {
4 | isTTY = true
5 | }
6 |
--------------------------------------------------------------------------------
/test/snapshots/test/fixtures/custom-snapshot-environment/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config';
2 |
3 | export default defineConfig({
4 | test: {
5 | snapshotEnvironment: './snapshot-environment.ts'
6 | }
7 | })
--------------------------------------------------------------------------------
/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.base.json",
3 | "compilerOptions": {
4 | "types": [
5 | "node",
6 | "vite/client"
7 | ]
8 | },
9 | "include": [
10 | "./**/*.ts"
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/test/ui/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "compilerOptions": {
4 | "baseUrl": "../..",
5 | "paths": {
6 | "vitest/node": ["./packages/vitest/dist/node.js"]
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/packages/vitest/src/node/types/worker.ts:
--------------------------------------------------------------------------------
1 | import type { MessagePort } from 'node:worker_threads'
2 | import type { ContextRPC } from '../../types/worker'
3 |
4 | export interface WorkerContext extends ContextRPC {
5 | port: MessagePort
6 | }
7 |
--------------------------------------------------------------------------------
/test/cli/fixtures/vm-threads/src/external/nested-default-cjs.cjs:
--------------------------------------------------------------------------------
1 | exports.default = {
2 | a: 'a',
3 | b: 'b',
4 | object: {
5 | h: 'h',
6 | },
7 | }
8 | Object.defineProperty(exports, '__esModule', { value: true, enumerable: false })
9 |
--------------------------------------------------------------------------------
/test/config/fixtures/conditions-test/conditions.test.js:
--------------------------------------------------------------------------------
1 | import { test, expect } from 'vitest';
2 | import { condition } from '../conditions-pkg';
3 |
4 | test('condition is correct', () => {
5 | expect(condition).toBe(TEST_CONDITION)
6 | })
7 |
--------------------------------------------------------------------------------
/test/config/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "compilerOptions": {
4 | "lib": ["DOM", "ESNext"],
5 | "types": ["vite/client"]
6 | },
7 | "exclude": [
8 | "**/dist/**"
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/test-that-looks-like-source-file.ts:
--------------------------------------------------------------------------------
1 | import { test, expect } from 'vitest'
2 | import { sum } from "./math"
3 |
4 | test("run tests on file that looks like source file", () => {
5 | expect(sum(1,2)).toBe(3)
6 | })
--------------------------------------------------------------------------------
/test/reporters/fixtures/all-skipped.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test.todo('2 + 3 = 5', () => {
4 | expect(2 + 3).toBe(5)
5 | })
6 |
7 | test.skip('3 + 3 = 6', () => {
8 | expect(3 + 3).toBe(6)
9 | })
10 |
--------------------------------------------------------------------------------
/test/snapshots/test/fixtures/skip-test/__snapshots__/repro.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`repro suite > inner case 1`] = `"hi-1"`;
4 |
5 | exports[`top-level case 1`] = `"hi-2"`;
6 |
--------------------------------------------------------------------------------
/test/typescript/failing/expect-error.test-d.ts:
--------------------------------------------------------------------------------
1 | import { expectTypeOf, test } from 'vitest'
2 |
3 | test('failing test with expect-error', () => {
4 | // @ts-expect-error expect nothing
5 | expectTypeOf(1).toEqualTypeOf()
6 | })
7 |
--------------------------------------------------------------------------------
/test/workspaces/space_1/vite.config.ts.timestamp-4345324-324424.mjs:
--------------------------------------------------------------------------------
1 | import { defineProject } from 'vitest/config'
2 |
3 | export default defineProject({
4 | test: {
5 | name: 'space_1',
6 | environment: 'happy-dom',
7 | },
8 | })
9 |
--------------------------------------------------------------------------------
/examples/sveltekit/src/lib/add.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest'
2 | import { add } from './add'
3 |
4 | describe('sum test', () => {
5 | it('adds 1 + 2 to equal 3', () => {
6 | expect(add(1, 2)).toBe(3)
7 | })
8 | })
9 |
--------------------------------------------------------------------------------
/packages/browser/types.ts:
--------------------------------------------------------------------------------
1 | export interface WSMessage {
2 | /**
3 | * Message type
4 | */
5 | type: string
6 |
7 | /**
8 | * Message Data
9 | */
10 | data: any
11 | }
12 |
13 | export type RunState = 'idle' | 'running'
14 |
--------------------------------------------------------------------------------
/packages/vitest/src/utils/debugger.ts:
--------------------------------------------------------------------------------
1 | import createDebug from 'debug'
2 |
3 | export function createDebugger(namespace: `vitest:${string}`) {
4 | const debug = createDebug(namespace)
5 | if (debug.enabled) {
6 | return debug
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/test-extend/test-rest-params.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | const myTest = test.extend({ a: 1 })
4 |
5 | // eslint-disable-next-line unused-imports/no-unused-vars
6 | myTest('', (...rest) => {
7 |
8 | })
9 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/test-extend/test-rest-props.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | const myTest = test.extend({ a: 1 })
4 |
5 | // eslint-disable-next-line unused-imports/no-unused-vars
6 | myTest('', ({ ...rest }) => {
7 |
8 | })
9 |
--------------------------------------------------------------------------------
/test/core/src/cjs/prototype-cjs.js:
--------------------------------------------------------------------------------
1 | exports.test = () => {
2 | // eslint-disable-next-line no-prototype-builtins
3 | return exports.hasOwnProperty('test')
4 | }
5 | exports.getPrototype = () => {
6 | return Object.getPrototypeOf(exports)
7 | }
8 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/all-passing-or-skipped.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('2 + 3 = 5', () => {
4 | expect(2 + 3).toBe(5)
5 | })
6 |
7 | test.skip('3 + 3 = 6', () => {
8 | expect(3 + 3).toBe(6)
9 | })
10 |
--------------------------------------------------------------------------------
/test/ui/fixtures/error.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, it } from "vitest"
2 |
3 | // https://github.com/vitest-dev/vitest/issues/5321
4 | it('escape html in error diff', () => {
5 | expect('').toBe("")
6 | })
7 |
--------------------------------------------------------------------------------
/docs/.vitepress/components/NonProjectOption.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 | *
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/benchmark/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vitest/test-benchmark",
3 | "type": "module",
4 | "private": true,
5 | "scripts": {
6 | "test": "vitest"
7 | },
8 | "devDependencies": {
9 | "vitest": "workspace:*"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/browser/test/injected.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('injected values are correct', () => {
4 | expect((globalThis as any).__injected).toEqual([
5 | 1,
6 | 2,
7 | 3,
8 | 4,
9 | ])
10 | })
11 |
--------------------------------------------------------------------------------
/test/cli/fixtures/list/describe-error.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest';
2 |
3 | describe('describe error', () => {
4 | throw new Error('describe error')
5 |
6 | it('wont run', () => {
7 | expect(true).toBe(true)
8 | })
9 | })
--------------------------------------------------------------------------------
/test/core/deps/dep1/esm/index.js:
--------------------------------------------------------------------------------
1 | // esm/index.js was detected as isValidNodeImport(id) = false
2 | // event if package.json has type = module,
3 | // which causes dual package hazard when other external esm import esm/index.js.
4 | export const data = {}
5 |
--------------------------------------------------------------------------------
/test/snapshots/test/fixtures/custom-serializers/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | snapshotSerializers: ['./serializer-1.js', './serializer-2.ts']
6 | }
7 | })
8 |
--------------------------------------------------------------------------------
/test/workspaces-browser/space_1/vitest.config.ts.timestamp-4345324-324424.mjs:
--------------------------------------------------------------------------------
1 | import { defineProject } from 'vitest/config'
2 |
3 | export default defineProject({
4 | test: {
5 | name: 'space_1',
6 | environment: 'happy-dom',
7 | },
8 | })
9 |
--------------------------------------------------------------------------------
/packages/ui/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "compilerOptions": {
4 | "jsx": "preserve",
5 | "skipLibCheck": true
6 | },
7 | "include": ["./client/**/*"],
8 | "exclude": ["dist", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/test-extend/test-without-destructuring.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest'
2 |
3 | const myTest = test.extend({ a: 1 })
4 |
5 | // eslint-disable-next-line unused-imports/no-unused-vars
6 | myTest('', (context) => {
7 |
8 | })
9 |
--------------------------------------------------------------------------------
/test/cli/fixtures/restricted-fs/tests/basic.spec.js:
--------------------------------------------------------------------------------
1 | import { expect, it } from 'vitest'
2 | import { multiply } from '../src/math'
3 |
4 | it('2 x 2 = 4', () => {
5 | expect(multiply(2, 2)).toBe(4)
6 | expect(multiply(2, 2)).toBe(Math.sqrt(16))
7 | })
8 |
--------------------------------------------------------------------------------
/test/vite-node/src/circular2/index.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-console */
2 | import { a } from './a'
3 | import { b } from './b'
4 |
5 | /**
6 | * index -> a -> b
7 | * ^ ^v
8 | * reg -> c
9 | */
10 |
11 | console.log(a, b)
12 |
--------------------------------------------------------------------------------
/examples/fastify/src/index.ts:
--------------------------------------------------------------------------------
1 | import app from './app'
2 |
3 | async function start() {
4 | try {
5 | await app.listen({ port: 3000 })
6 | }
7 | catch (err) {
8 | app.log.error(err)
9 | process.exit(1)
10 | }
11 | }
12 |
13 | start()
14 |
--------------------------------------------------------------------------------
/examples/preact/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "module": "Node16",
5 | "moduleResolution": "Node16",
6 | "allowSyntheticDefaultImports": true
7 | },
8 | "include": ["vite.config.ts"]
9 | }
10 |
--------------------------------------------------------------------------------
/examples/react/vitest.config.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | import { defineConfig } from 'vite'
4 |
5 | export default defineConfig({
6 | test: {
7 | environment: 'jsdom',
8 | setupFiles: ['./vitest.setup.ts'],
9 | },
10 | })
11 |
--------------------------------------------------------------------------------
/packages/ui/client/utils/escape.ts:
--------------------------------------------------------------------------------
1 | export function escapeHtml(unsafe: string) {
2 | return unsafe
3 | .replace(/&/g, '&')
4 | .replace(//g, '>')
6 | .replace(/"/g, '"')
7 | .replace(/'/g, ''')
8 | }
9 |
--------------------------------------------------------------------------------
/test/browser/cjs-lib/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vitest/cjs-lib",
3 | "type": "commonjs",
4 | "exports": {
5 | "./lib": {
6 | "types": "./lib.d.ts",
7 | "default": "./lib.mjs"
8 | },
9 | ".": "./index.js"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/mock-import-proxy-module.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test, vi } from './proxy-module'
2 |
3 | // This can be used only when imported directly from vitest
4 | vi.mock('vite')
5 |
6 | test('hi', () => {
7 | expect(1 + 1).toEqual(2)
8 | })
9 |
--------------------------------------------------------------------------------
/test/config/fixtures/exclude/string.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | import { capitalize } from './string'
4 |
5 | test('should capitalize strings correctly', () => {
6 | expect(capitalize('i Love Vitest')).toBe('I love vitest')
7 | })
8 |
--------------------------------------------------------------------------------
/test/core/test/alias.test.ts:
--------------------------------------------------------------------------------
1 | // @ts-expect-error aliased to ../src/aliased-mod.ts
2 | import { isAliased } from 'test-alias'
3 | import { expect, test } from 'vitest'
4 |
5 | test('check that test.alias works', () => {
6 | expect(isAliased).toBe(true)
7 | })
8 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/Vue/vue.shim.d.ts:
--------------------------------------------------------------------------------
1 | declare const MY_CONSTANT: string
2 |
3 | declare module '*.vue' {
4 | import type { DefineComponent } from 'vue'
5 |
6 | const component: DefineComponent<{}, {}, any>
7 | export default component
8 | }
9 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/should-be-excluded-by-default.cts:
--------------------------------------------------------------------------------
1 | /*
2 | * Vite does not transform `*.cts` files.
3 | * If this file is picked by Istanbul provider, it will make Babel crash on TS syntax.
4 | */
5 | interface Props {
6 | name: string;
7 | }
8 |
--------------------------------------------------------------------------------
/packages/spy/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "compilerOptions": {
4 | "moduleResolution": "Bundler",
5 | "isolatedDeclarations": true
6 | },
7 | "include": ["./src/**/*.ts"],
8 | "exclude": ["./dist"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/utils/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "compilerOptions": {
4 | "moduleResolution": "Bundler",
5 | "isolatedDeclarations": true
6 | },
7 | "include": ["src/**/*"],
8 | "exclude": ["**/dist/**"]
9 | }
10 |
--------------------------------------------------------------------------------
/test/config/fixtures/mode/example.benchmark.ts:
--------------------------------------------------------------------------------
1 | import { bench, describe } from 'vitest'
2 |
3 | describe('example', () => {
4 | bench('simple', () => {
5 | let _ = 0
6 | _ += 1
7 | }, { iterations: 1, time: 1, warmupIterations: 0, warmupTime: 0 })
8 | })
9 |
--------------------------------------------------------------------------------
/test/typescript/test-d/nested-suite1.test-d.ts:
--------------------------------------------------------------------------------
1 | import { describe, test } from 'vitest'
2 |
3 | describe('suite-A', () => {
4 | describe('suite-B', () => {
5 | test('case-X', () => {
6 | })
7 | })
8 | })
9 |
10 | test('case-Y', () => {
11 | })
12 |
--------------------------------------------------------------------------------
/packages/snapshot/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "compilerOptions": {
4 | "moduleResolution": "Bundler",
5 | "isolatedDeclarations": true
6 | },
7 | "include": ["./src/**/*.ts"],
8 | "exclude": ["./dist"]
9 | }
10 |
--------------------------------------------------------------------------------
/test/browser/fixtures/mocking/src/calculator.ts:
--------------------------------------------------------------------------------
1 | import { plus } from './actions'
2 |
3 | export function calculator(operation: 'plus', a: number, b: number) {
4 | if (operation === 'plus')
5 | return plus(a, b)
6 |
7 | throw new Error('unknown operation')
8 | }
9 |
--------------------------------------------------------------------------------
/test/browser/src/calculator.ts:
--------------------------------------------------------------------------------
1 | import { plus } from './actions'
2 |
3 | export function calculator(operation: 'plus', a: number, b: number) {
4 | if (operation === 'plus') {
5 | return plus(a, b)
6 | }
7 |
8 | throw new Error('unknown operation')
9 | }
10 |
--------------------------------------------------------------------------------
/test/cli/fixtures/list/custom.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | include: ['basic.test.ts', 'math.test.ts'],
6 | name: 'custom',
7 | includeTaskLocation: true,
8 | },
9 | })
10 |
--------------------------------------------------------------------------------
/test/config/fixtures/retry/retry.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | let number = 0
4 | test('should passed', () => {
5 | expect(number++).toBe(3)
6 | })
7 |
8 | test('retry but still failed', () => {
9 | expect(number++).toBe(4)
10 | })
11 |
--------------------------------------------------------------------------------
/test/core/src/mockedE.ts:
--------------------------------------------------------------------------------
1 | export const symbolFn = Symbol.for('symbolFn')
2 |
3 | export class MockedE {
4 | public testFn(arg: string) {
5 | return arg.repeat(2)
6 | }
7 |
8 | public [symbolFn](arg: string) {
9 | return arg.repeat(2)
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/core/src/web-worker/sharedWorker.ts:
--------------------------------------------------------------------------------
1 | self.addEventListener('connect', (event) => {
2 | const e = event as MessageEvent
3 | const port = e.ports[0]
4 |
5 | port.onmessage = (e) => {
6 | port.postMessage(e.data)
7 | }
8 |
9 | port.start()
10 | })
11 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/test/ignore-hints-fixture.test.ts:
--------------------------------------------------------------------------------
1 | import { test, expect} from "vitest";
2 | import { first, second } from '../src/ignore-hints';
3 |
4 | test("cover some lines", () => {
5 | expect(first()).toBe("First")
6 | expect(second()).toBe("Second")
7 | })
--------------------------------------------------------------------------------
/test/browser/fixtures/mocking/src/mocks_calculator.ts:
--------------------------------------------------------------------------------
1 | import { plus } from './actions'
2 |
3 | export function calculator(operation: 'plus', a: number, b: number) {
4 | if (operation === 'plus')
5 | return plus(a, b)
6 |
7 | throw new Error('unknown operation')
8 | }
9 |
--------------------------------------------------------------------------------
/test/cli/fixtures/expect-soft/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | test: {
5 | pool: 'forks',
6 | poolOptions: {
7 | forks: {
8 | isolate: false,
9 | },
10 | },
11 | },
12 | })
13 |
--------------------------------------------------------------------------------
/test/cli/fixtures/stacktraces/add-in-js.test.js:
--------------------------------------------------------------------------------
1 | /* body */
2 | import { expect, it } from 'vitest'
3 | import { add } from './utils'
4 |
5 | it('add', () => {
6 | expect(add()).toBe(100)
7 | expect(add(1)).toBe(1)
8 | return expect(add(1, 2, 3)).toBe(6)
9 | })
10 |
--------------------------------------------------------------------------------
/test/core/src/mocks/integration.ts:
--------------------------------------------------------------------------------
1 | import { useJwt } from '@vueuse/integrations/useJwt'
2 | import { ref } from 'vue'
3 |
4 | export function createStore() {
5 | const encoded = ref('123')
6 | const { payload } = useJwt(encoded)
7 |
8 | return { payload }
9 | }
10 |
--------------------------------------------------------------------------------
/test/core/src/mocks/set-foo.ts:
--------------------------------------------------------------------------------
1 | import { afterEach, beforeEach } from 'vitest'
2 |
3 | // eslint-disable-next-line import/no-mutable-exports
4 | export let foo: number
5 |
6 | beforeEach(() => {
7 | foo = 1
8 | })
9 |
10 | afterEach(() => {
11 | foo = 2
12 | })
13 |
--------------------------------------------------------------------------------
/test/core/test/inlined.test.ts:
--------------------------------------------------------------------------------
1 | // @ts-expect-error not typed lib
2 | import typeOfModule from 'inline-lib'
3 | import { expect, test } from 'vitest'
4 |
5 | test('inline lib has exports injected even though it is ESM', () => {
6 | expect(typeOfModule()).toBe('object')
7 | })
8 |
--------------------------------------------------------------------------------
/test/ui/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | dir: './fixtures',
6 | environment: 'happy-dom',
7 | coverage: {
8 | reportOnFailure: true,
9 | },
10 | },
11 | })
12 |
--------------------------------------------------------------------------------
/test/workspaces/space_3/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineProject } from 'vitest/config'
2 |
3 | export default defineProject({
4 | test: {
5 | include: ['**/*.space-3-test.ts'],
6 | environment: 'node',
7 | globalSetup: './localSetup.ts',
8 | },
9 | })
10 |
--------------------------------------------------------------------------------
/examples/workspace/packages/server/src/index.ts:
--------------------------------------------------------------------------------
1 | import app from './app'
2 |
3 | async function start() {
4 | try {
5 | await app.listen({ port: 3000 })
6 | }
7 | catch (err) {
8 | app.log.error(err)
9 | process.exit(1)
10 | }
11 | }
12 |
13 | start()
14 |
--------------------------------------------------------------------------------
/packages/vitest/src/paths.ts:
--------------------------------------------------------------------------------
1 | import url from 'node:url'
2 | import { resolve } from 'pathe'
3 |
4 | export const rootDir = resolve(url.fileURLToPath(import.meta.url), '../../')
5 | export const distDir = resolve(
6 | url.fileURLToPath(import.meta.url),
7 | '../../dist',
8 | )
9 |
--------------------------------------------------------------------------------
/packages/vitest/src/utils/source-map.ts:
--------------------------------------------------------------------------------
1 | export {
2 | lineSplitRE,
3 | positionToOffset,
4 | offsetToLineNumber,
5 | } from '@vitest/utils'
6 | export {
7 | parseSingleStack,
8 | parseStacktrace,
9 | parseErrorStacktrace,
10 | } from '@vitest/utils/source-map'
11 |
--------------------------------------------------------------------------------
/test/cli/fixtures/stacktraces/add-in-imba.test.imba:
--------------------------------------------------------------------------------
1 | import {it, expect} from 'vitest'
2 |
3 | export def add(...args)
4 | return args.reduce((do(a, b) a + b), 0)
5 |
6 | it "add", do
7 | expect(add()).toBe 0
8 | expect(add(1)).toBe 3
9 | expect(add(1, 2, 3)).toBe 6
10 |
--------------------------------------------------------------------------------
/test/core/test/snapshots-outside.ts:
--------------------------------------------------------------------------------
1 | import { expect } from 'vitest'
2 |
3 | export function testOutsideInlineSnapshot() {
4 | return (() => {
5 | expect({ foo: 'bar' }).toMatchInlineSnapshot(`
6 | {
7 | "foo": "bar",
8 | }
9 | `)
10 | })()
11 | }
12 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/duration/basic.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest';
2 |
3 | test('fast', () => {
4 | });
5 |
6 | test('slow', async () => {
7 | await sleep(300)
8 | });
9 |
10 | const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))
11 |
--------------------------------------------------------------------------------
/test/browser/fixtures/mocking/mocked-__mocks__.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test, vi } from 'vitest'
2 | import { calculator } from './src/mocks_calculator'
3 |
4 | vi.mock(import('./src/mocks_calculator'))
5 |
6 | test('adds', () => {
7 | expect(calculator('plus', 1, 2)).toBe(42)
8 | })
9 |
--------------------------------------------------------------------------------
/test/core/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Core Tests
7 |
8 |
9 | Nothing is rendered
10 |
11 |
--------------------------------------------------------------------------------
/test/core/test/__snapshots__/snapshot-concurrent.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`four 1`] = `"four"`;
4 |
5 | exports[`one 1`] = `"one"`;
6 |
7 | exports[`three 1`] = `"three"`;
8 |
9 | exports[`two 1`] = `"two"`;
10 |
--------------------------------------------------------------------------------
/test/core/test/env-glob-dom/env-glob.overrides.spec.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | /**
4 | * @vitest-environment edge-runtime
5 | */
6 |
7 | test('glob on folder overrides', () => {
8 | expect(expect.getState().environment).toBe('edge-runtime')
9 | })
10 |
--------------------------------------------------------------------------------
/test/core/test/fixtures/snapshots/multiple/input.json:
--------------------------------------------------------------------------------
1 | [
2 | [
3 | ".text-red",
4 | {
5 | "color": "red"
6 | }
7 | ],
8 | [
9 | ".text-lg",
10 | {
11 | "font-size": "1.25rem",
12 | "line-height": "1.75rem"
13 | }
14 | ]
15 | ]
16 |
--------------------------------------------------------------------------------
/test/core/test/isolate.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, it } from 'vitest'
2 |
3 | // this should keep working after reloads
4 | it('isolate', () => {
5 | const g = globalThis as any
6 | expect(g.fooooo).toBe(undefined)
7 | g.fooooo = true
8 | expect(g.fooooo).toBe(true)
9 | })
10 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/test/import-attributes-fixture.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from "vitest";
2 | import {getJSON} from "../src/json-data-import";
3 | import json from "../src/json-data.json";
4 |
5 | test("JSON data", () => {
6 | expect(getJSON()).toEqual(json);
7 | });
8 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/code-frame-line-limit.test.ts:
--------------------------------------------------------------------------------
1 | import { test, expect } from "vitest"
2 |
3 | test("basic", () => {
4 | // line length is 85 but highlight makes this line 245 chars
5 | expect([{ prop: 7 }, { prop: 7 }, { prop: 7 }, { prop: 7 }]).toBe([{ another: 8 }])
6 | })
7 |
--------------------------------------------------------------------------------
/test/ui/playwright.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig, devices } from '@playwright/test'
2 |
3 | export default defineConfig({
4 | testDir: './test',
5 | projects: [
6 | {
7 | name: 'chromium',
8 | use: devices['Desktop Chrome'],
9 | },
10 | ],
11 | })
12 |
--------------------------------------------------------------------------------
/examples/lit/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2020",
4 | "useDefineForClassFields": false,
5 | "experimentalDecorators": true,
6 | "module": "node16",
7 | "moduleResolution": "Node16",
8 | "verbatimModuleSyntax": true
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/examples/solid/test/__snapshots__/Hello.test.jsx.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[` > renders 1`] = `"4 x 2 = 8
"`;
4 |
5 | exports[` > updates 1`] = `"4 x 3 = 12
"`;
6 |
--------------------------------------------------------------------------------
/packages/vitest/src/integrations/utils.ts:
--------------------------------------------------------------------------------
1 | // Runtime utils exposed to `vitest`
2 |
3 | export function getRunningMode() {
4 | return process.env.VITEST_MODE === 'WATCH' ? 'watch' : 'run'
5 | }
6 |
7 | export function isWatchMode() {
8 | return getRunningMode() === 'watch'
9 | }
10 |
--------------------------------------------------------------------------------
/test/core/types/env.d.ts:
--------------------------------------------------------------------------------
1 | interface ImportMeta {
2 | readonly env: ImportMetaEnv
3 | }
4 |
5 | interface ImportMetaEnv {
6 | [key: string]: string | boolean | undefined
7 | BASE_URL: string
8 | MODE: string
9 | DEV: boolean
10 | PROD: boolean
11 | SSR: boolean
12 | }
13 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/json-fail.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | // I am comment1
4 | // I am comment2
5 | test('should fail', () => {
6 | // eslint-disable-next-line no-console
7 | console.log('json-fail>should fail')
8 | expect(2).toEqual(1)
9 | })
10 |
--------------------------------------------------------------------------------
/packages/vitest/import-meta.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | // https://github.com/microsoft/TypeScript/issues/45096
4 | // TypeScript has a bug that makes
5 | // not possible in userland. This file provides a workaround for now.
6 |
--------------------------------------------------------------------------------
/test/browser/test/polyfill-lib.test.ts:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line unicorn/prefer-node-protocol
2 | import * as url from 'url'
3 | import { expect, test } from 'vitest'
4 |
5 | test('url is polifylled because it\'s installed in dependencies', () => {
6 | expect(url.format).toBeDefined()
7 | })
8 |
--------------------------------------------------------------------------------
/test/core/src/mocks/moduleWithSymbol.ts:
--------------------------------------------------------------------------------
1 | const methodSymbol = Symbol('x')
2 |
3 | const moduleWithSymbol = {
4 | warn() {
5 | return this[methodSymbol]()
6 | },
7 | [methodSymbol]() {
8 | return 'hello'
9 | },
10 | }
11 |
12 | export { methodSymbol, moduleWithSymbol }
13 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/default/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | process.stdin.isTTY = true
4 | process.stdin.setRawMode = () => process.stdin
5 |
6 | export default defineConfig({
7 | test: {
8 | reporters: './MockReporter',
9 | },
10 | })
11 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/error-props/basic.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest';
2 |
3 | test('throws', () => {
4 | const error = new Error('error with properties')
5 | Object.assign(error, {
6 | code: 404,
7 | status: 'not found',
8 | })
9 | throw error
10 | });
11 |
12 |
--------------------------------------------------------------------------------
/test/workspaces/space-multi-transform/test/project-1.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | import { run } from '../src/multi-transform'
4 |
5 | test('cover some branches', () => {
6 | expect(run('project-1')).toBe(1)
7 |
8 | expect(run('last branch')).toBe(3)
9 | })
10 |
--------------------------------------------------------------------------------
/test/workspaces/space-multi-transform/test/project-2.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | import { run } from '../src/multi-transform'
4 |
5 | test('cover some branches', () => {
6 | expect(run('project-2')).toBe(2)
7 |
8 | expect(run('last branch')).toBe(3)
9 | })
10 |
--------------------------------------------------------------------------------
/examples/preact/src/hooks/useCount.ts:
--------------------------------------------------------------------------------
1 | import { useCallback, useState } from 'preact/hooks'
2 |
3 | export function useCount() {
4 | const [count, setCount] = useState(0)
5 | const inc = useCallback(() => setCount(x => x + 1), [])
6 | return {
7 | count,
8 | inc,
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/packages/browser/providers.d.ts:
--------------------------------------------------------------------------------
1 | import type { BrowserProviderModule } from 'vitest/node'
2 |
3 | declare const webdriverio: BrowserProviderModule
4 | declare const playwright: BrowserProviderModule
5 | declare const preview: BrowserProviderModule
6 |
7 | export { webdriverio, playwright, preview }
8 |
--------------------------------------------------------------------------------
/test/browser/test/failing.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, it } from 'vitest'
2 | import { throwError } from '../src/error'
3 |
4 | it('correctly fails and prints a diff', () => {
5 | expect(1).toBe(2)
6 | })
7 |
8 | it('correctly print error in another file', () => {
9 | throwError()
10 | })
11 |
--------------------------------------------------------------------------------
/packages/vitest/src/public/environments.ts:
--------------------------------------------------------------------------------
1 | export { environments as builtinEnvironments } from '../integrations/env/index'
2 | export { populateGlobal } from '../integrations/env/utils'
3 | export type {
4 | EnvironmentReturn,
5 | VmEnvironmentReturn,
6 | Environment,
7 | } from '../types/environment'
8 |
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/workspace/packages/packageB/index.test.js:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest';
2 | import getNumber from './index';
3 | describe('getNumber', () => {
4 | const result = getNumber();
5 | it('should return 3', () => {
6 | expect(result).toBe(3);
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/test/core/src/mocks/log.ts:
--------------------------------------------------------------------------------
1 | const writeSym = Symbol('write')
2 | const proto = {
3 | [writeSym]() {
4 | return 'hello'
5 | },
6 | }
7 | const logger = {
8 | warn() {
9 | ;(this as any)[writeSym]()
10 | },
11 | }
12 | Object.setPrototypeOf(logger, proto)
13 | export default logger
14 |
--------------------------------------------------------------------------------
/test/core/test/mocking/custom-module-directory.spec.ts:
--------------------------------------------------------------------------------
1 | // @ts-expect-error not typed aliased import
2 | import getState from 'custom-lib'
3 | import { expect, it, vi } from 'vitest'
4 |
5 | vi.mock('custom-lib')
6 |
7 | it('state is mocked', () => {
8 | expect(getState()).toBe('mocked')
9 | })
10 |
--------------------------------------------------------------------------------
/test/core/test/mocking/has-extension.spec.ts:
--------------------------------------------------------------------------------
1 | // @ts-expect-error mocked module
2 | import { mocked } from 'extension.js'
3 | import { expect, test, vi } from 'vitest'
4 |
5 | vi.mock('extension.js')
6 |
7 | test('module with extension is mocked', () => {
8 | expect(mocked).toBe(true)
9 | })
10 |
--------------------------------------------------------------------------------
/test/global-setup/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vitest/test-global-setup",
3 | "type": "module",
4 | "private": true,
5 | "scripts": {
6 | "test": "vitest",
7 | "coverage": "vitest run --coverage"
8 | },
9 | "devDependencies": {
10 | "vitest": "workspace:*"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/global-setup/setupFiles/without-relative-path-prefix.ts:
--------------------------------------------------------------------------------
1 | import { afterAll, beforeAll } from 'vitest'
2 |
3 | beforeAll(() => {
4 | // @ts-expect-error type
5 | globalThis.loaded = true
6 | })
7 |
8 | afterAll(() => {
9 | // @ts-expect-error type
10 | delete globalThis.loaded
11 | })
12 |
--------------------------------------------------------------------------------
/packages/vitest/README.md:
--------------------------------------------------------------------------------
1 | # vitest
2 |
3 | [](https://www.npmjs.com/package/vitest)
4 |
5 | Next generation testing framework powered by Vite.
6 |
7 | [GitHub](https://github.com/vitest-dev/vitest) | [Documentation](https://vitest.dev/)
8 |
--------------------------------------------------------------------------------
/test/cli/fixtures/git-changed/workspace/packages/packageA/index.test.js:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest';
2 | import getLetter from './index';
3 | describe('getLetter', () => {
4 | const result = getLetter();
5 | it('should return c', () => {
6 | expect(result).toBe('c');
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/test/core/test/builtin.test.ts:
--------------------------------------------------------------------------------
1 | import testModule, { run } from 'node:test'
2 | import { expect, it } from 'vitest'
3 |
4 | it('node:test works correctly', () => {
5 | expect(run).toBeTypeOf('function')
6 | expect(testModule).toBeTypeOf('function')
7 | expect(testModule.run).toBeTypeOf('function')
8 | })
9 |
--------------------------------------------------------------------------------
/test/core/test/dom-single-line-options.test.ts:
--------------------------------------------------------------------------------
1 | /** @vitest-environment jsdom */
2 |
3 | /** @vitest-environment-options { "url": "https://example.com/" } */
4 |
5 | import { expect, it } from 'vitest'
6 |
7 | it('parse single line environment options', () => expect(location.href).toBe('https://example.com/'))
8 |
--------------------------------------------------------------------------------
/test/optimize-deps/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vitest/test-optimize-deps",
3 | "type": "module",
4 | "private": true,
5 | "scripts": {
6 | "test": "vitest"
7 | },
8 | "devDependencies": {
9 | "@vitest/test-dep-url": "file:./dep-url",
10 | "vitest": "workspace:*"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/reporters/custom-reporter.vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 | import TestReporter from './src/custom-reporter'
3 |
4 | export default defineConfig({
5 | test: {
6 | include: ['tests/reporters.spec.ts'],
7 | reporters: [new TestReporter()],
8 | },
9 | })
10 |
--------------------------------------------------------------------------------
/test/snapshots/test/fixtures/custom-snapshot-environment/test/snapshots.test.ts:
--------------------------------------------------------------------------------
1 | import {test, expect} from 'vitest'
2 |
3 | test('regular snapshot', () => {
4 | expect({ a: 1 }).toMatchSnapshot()
5 | })
6 |
7 | test('inline snapshot', () => {
8 | expect({ a: 1 }).toMatchInlineSnapshot()
9 | })
10 |
--------------------------------------------------------------------------------
/test/typescript/test/vitest.empty.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | typecheck: {
6 | enabled: true,
7 | include: ['**/fail.test-d.ts'],
8 | tsconfig: '../tsconfig.empty.json',
9 | },
10 | },
11 | })
12 |
--------------------------------------------------------------------------------
/test/workspaces/space_shared/test.spec.ts:
--------------------------------------------------------------------------------
1 | import { expect, it } from 'vitest'
2 |
3 | declare global {
4 | const testValue: string
5 | }
6 |
7 | it('the same file works with different projects', () => {
8 | expect(testValue).toBe(expect.getState().environment === 'node' ? 'node' : 'jsdom')
9 | })
10 |
--------------------------------------------------------------------------------
/packages/vitest/src/integrations/chai/config.ts:
--------------------------------------------------------------------------------
1 | import * as chai from 'chai'
2 |
3 | export function setupChaiConfig(config: ChaiConfig) {
4 | Object.assign(chai.config, config)
5 | }
6 |
7 | export type ChaiConfig = Omit<
8 | Partial,
9 | 'useProxy' | 'proxyExcludedKeys'
10 | >
11 |
--------------------------------------------------------------------------------
/test/browser/fixtures/mocking/automocked.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test, vi } from 'vitest'
2 | import { calculator } from './src/calculator'
3 |
4 | vi.mock('./src/calculator')
5 |
6 | test('adds', () => {
7 | vi.mocked(calculator).mockReturnValue(4)
8 | expect(calculator('plus', 1, 2)).toBe(4)
9 | })
10 |
--------------------------------------------------------------------------------
/test/reporters/deps-reporter.vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | include: ['tests/reporters.spec.ts'],
6 | reporters: ['pkg-reporter', 'vitest-sonar-reporter'],
7 | outputFile: './sonar-config.xml',
8 | },
9 | })
10 |
--------------------------------------------------------------------------------
/test/workspaces-browser/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vitest/test-workspaces-browser",
3 | "type": "module",
4 | "private": true,
5 | "scripts": {
6 | "test": "vitest run"
7 | },
8 | "devDependencies": {
9 | "@vitest/browser": "workspace:^",
10 | "vitest": "workspace:*"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/config/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vitest/test-config",
3 | "type": "module",
4 | "private": true,
5 | "scripts": {
6 | "test": "vitest --typecheck.enabled"
7 | },
8 | "devDependencies": {
9 | "execa": "^8.0.1",
10 | "vite": "latest",
11 | "vitest": "workspace:*"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/test/multi-environment-fixture-ssr.test.ts:
--------------------------------------------------------------------------------
1 | // @vitest-environment node
2 |
3 | import { expect, test } from 'vitest'
4 | import { sum } from '../src/multi-environment'
5 |
6 | test('runs on server', () => {
7 | expect(sum(2, 2)).toBe(4)
8 | expect(sum(100, 200)).toBe(300)
9 | })
10 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/test/multi-environment-fixture-web.test.ts:
--------------------------------------------------------------------------------
1 | // @vitest-environment jsdom
2 |
3 | import { expect, test } from 'vitest'
4 | import { sum } from '../src/multi-environment'
5 |
6 | test('runs on client', () => {
7 | expect(sum(1, 2)).toBe(3)
8 | expect(sum(10, 23)).toBe(33)
9 | })
10 |
--------------------------------------------------------------------------------
/packages/pretty-format/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "compilerOptions": {
4 | "lib": ["ESNext", "DOM", "DOM.Iterable"],
5 | "moduleResolution": "Bundler",
6 | "isolatedDeclarations": true
7 | },
8 | "include": ["src/**/*"],
9 | "exclude": ["**/dist/**"]
10 | }
11 |
--------------------------------------------------------------------------------
/packages/runner/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "compilerOptions": {
4 | "target": "ESNext",
5 | "module": "ESNext",
6 | "moduleResolution": "Bundler",
7 | "isolatedDeclarations": true
8 | },
9 | "include": ["./src/**/*.ts"],
10 | "exclude": ["./dist"]
11 | }
12 |
--------------------------------------------------------------------------------
/packages/vitest/src/node/types/vite.ts:
--------------------------------------------------------------------------------
1 | import type { InlineConfig } from './config'
2 |
3 | type VitestInlineConfig = InlineConfig
4 |
5 | declare module 'vite' {
6 | interface UserConfig {
7 | /**
8 | * Options for Vitest
9 | */
10 | test?: VitestInlineConfig
11 | }
12 | }
13 |
14 | export {}
15 |
--------------------------------------------------------------------------------
/test/benchmark/fixtures/sequential/f2.bench.ts:
--------------------------------------------------------------------------------
1 | import { bench, describe } from "vitest"
2 | import { appendLog, benchOptions, sleepBench } from "./helper";
3 |
4 | describe("S1", () => {
5 | bench("B1", async () => {
6 | await appendLog("F2 / S1 / B1")
7 | await sleepBench();
8 | }, benchOptions)
9 | })
10 |
--------------------------------------------------------------------------------
/test/vite-node/src/deps.ts:
--------------------------------------------------------------------------------
1 | import './deps.css'
2 |
3 | // eslint-disable-next-line no-console
4 | console.log('deps')
5 |
6 | export {}
7 |
8 | if (import.meta.hot) {
9 | import.meta.hot.accept(() => {
10 | // eslint-disable-next-line no-console
11 | console.log('[deps.ts] hot reload!')
12 | })
13 | }
14 |
--------------------------------------------------------------------------------
/test/workspaces/space_3/global-provide.space-3-test.ts:
--------------------------------------------------------------------------------
1 | import { expect, inject, test } from 'vitest'
2 |
3 | test('global setup provides data correctly', () => {
4 | expect(inject('globalSetup')).toBe(true)
5 | expect(inject('globalSetupOverriden')).toBe(true)
6 | expect(inject('invalidValue')).toBe(undefined)
7 | })
8 |
--------------------------------------------------------------------------------
/test/workspaces/space_3/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | plugins: [
5 | {
6 | name: 'throw-error',
7 | config() {
8 | throw new Error('This file should not initiate a workspace project.')
9 | },
10 | },
11 | ],
12 | })
13 |
--------------------------------------------------------------------------------
/packages/expect/src/constants.ts:
--------------------------------------------------------------------------------
1 | export const MATCHERS_OBJECT = Symbol.for('matchers-object')
2 | export const JEST_MATCHERS_OBJECT = Symbol.for('$$jest-matchers-object')
3 | export const GLOBAL_EXPECT = Symbol.for('expect-global')
4 | export const ASYMMETRIC_MATCHERS_OBJECT = Symbol.for(
5 | 'asymmetric-matchers-object',
6 | )
7 |
--------------------------------------------------------------------------------
/packages/vitest/src/integrations/globals.ts:
--------------------------------------------------------------------------------
1 | import { globalApis } from '../constants'
2 | import * as index from '../public/index'
3 |
4 | export function registerApiGlobally() {
5 | globalApis.forEach((api) => {
6 | // @ts-expect-error I know what I am doing :P
7 | globalThis[api] = index[api]
8 | })
9 | }
10 |
--------------------------------------------------------------------------------
/packages/vitest/src/node/reporters/benchmark/index.ts:
--------------------------------------------------------------------------------
1 | import { VerboseReporter } from '../verbose'
2 | import { TableReporter } from './table'
3 |
4 | export const BenchmarkReportsMap = {
5 | default: TableReporter,
6 | verbose: VerboseReporter,
7 | }
8 | export type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap
9 |
--------------------------------------------------------------------------------
/test/browser/fixtures/mocking/mocking-dep.test.ts:
--------------------------------------------------------------------------------
1 | import { a } from '@vitest/cjs-lib'
2 | import { expect, test, vi } from 'vitest'
3 |
4 | vi.mock(import('@vitest/cjs-lib'), () => {
5 | return {
6 | a: 'mocked',
7 | }
8 | })
9 |
10 | test('mocking works correctly', () => {
11 | expect(a).toBe('mocked')
12 | })
13 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/unhandled.test.ts:
--------------------------------------------------------------------------------
1 | // @vitest-environment jsdom
2 |
3 | import { expect, test } from 'vitest'
4 |
5 | test('unhandled exception', () => {
6 | expect(1).toBe(1)
7 | addEventListener('custom', () => {
8 | throw new Error('some error')
9 | })
10 | dispatchEvent(new Event('custom'))
11 | })
12 |
--------------------------------------------------------------------------------
/test/config/fixtures/mode/vitest.test.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig((env) => {
4 | if (env.mode !== 'test') {
5 | console.error('env.mode: ', env.mode)
6 | throw new Error('env.mode should be equal to "test"')
7 | }
8 |
9 | return ({})
10 | })
11 |
--------------------------------------------------------------------------------
/test/core/test/external-module-directory.test.ts:
--------------------------------------------------------------------------------
1 | // @ts-expect-error not typed aliased import
2 | import getModuleType from 'custom-lib'
3 | import { expect, it } from 'vitest'
4 |
5 | it('custom-lib is externalized because it\'s a valid esm file in module directory', () => {
6 | expect(getModuleType()).toBe('undefined')
7 | })
8 |
--------------------------------------------------------------------------------
/test/core/test/mocking/spaced.spec.ts:
--------------------------------------------------------------------------------
1 | import { expect, test, vi } from 'vitest'
2 | import { thisIsOk } from '../../src/mocks/has space in path'
3 |
4 | vi.mock('../../src/mocks/has space in path', () => ({ thisIsOk: true }))
5 |
6 | test('modules with spaces in name is mocked', () => {
7 | expect(thisIsOk).toBe(true)
8 | })
9 |
--------------------------------------------------------------------------------
/test/vite-node/src/circular1/index.ts:
--------------------------------------------------------------------------------
1 | import { a } from './a'
2 | import { b } from './b'
3 |
4 | export const index = 'index'
5 |
6 | export function foo() {
7 | return index
8 | }
9 |
10 | export * from './a'
11 | export * from './b'
12 |
13 | // eslint-disable-next-line no-console
14 | console.log(a(), b(), index)
15 |
--------------------------------------------------------------------------------
/test/vite-node/src/self-export-example1.ts:
--------------------------------------------------------------------------------
1 | // const ansiEscapes = module.exports
2 | // module.exports.default = ansiEscapes
3 | // ansiEscapes.HelloWorld = 1
4 | // console.log(ansiEscapes.HelloWorld);
5 |
6 | import inquirer from 'inquirer'
7 |
8 | // eslint-disable-next-line no-console
9 | console.log(inquirer.prompt)
10 |
--------------------------------------------------------------------------------
/test/workspaces/space_3/math.space-3-test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 | import { sum } from '../src/math'
3 | import { multiple } from './src/multiply'
4 |
5 | test('2 x 2 = 4', () => {
6 | expect(multiple(2, 2)).toBe(4)
7 | })
8 |
9 | test('2 + 2 = 4', () => {
10 | expect(sum(2, 2)).toBe(4)
11 | })
12 |
--------------------------------------------------------------------------------
/examples/sveltekit/src/app.d.ts:
--------------------------------------------------------------------------------
1 | // See https://kit.svelte.dev/docs/types#app
2 | // for information about these interfaces
3 | declare global {
4 | namespace App {
5 | // interface Error {}
6 | // interface Locals {}
7 | // interface PageData {}
8 | // interface Platform {}
9 | }
10 | }
11 |
12 | export {}
13 |
--------------------------------------------------------------------------------
/packages/browser/providers/webdriverio.d.ts:
--------------------------------------------------------------------------------
1 | import type { RemoteOptions } from 'webdriverio'
2 | import '../matchers.js'
3 |
4 | declare module 'vitest/node' {
5 | interface BrowserProviderOptions extends RemoteOptions {}
6 |
7 | export interface BrowserCommandContext {
8 | browser: WebdriverIO.Browser
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/packages/runner/src/errors.ts:
--------------------------------------------------------------------------------
1 | import type { TaskBase } from './types/tasks'
2 |
3 | export class PendingError extends Error {
4 | public code = 'VITEST_PENDING'
5 | public taskId: string
6 |
7 | constructor(public message: string, task: TaskBase) {
8 | super(message)
9 | this.taskId = task.id
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/cli/fixtures/custom-file-env/custom-file-env.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('custom env is defined', () => {
4 | expect(expect.getState().environment).toBe('custom')
5 | expect((globalThis as any).testEnvironment).toBe('custom')
6 | expect((globalThis as any).option).toBe('custom-option')
7 | })
8 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | test: {
5 | pool: 'forks',
6 | poolOptions: {
7 | forks: {
8 | isolate: false,
9 | },
10 | },
11 | expect: {
12 | requireAssertions: true,
13 | }
14 | },
15 | })
16 |
--------------------------------------------------------------------------------
/test/config/fixtures/workspace/browser/workspace-with-browser.ts:
--------------------------------------------------------------------------------
1 | import { defineWorkspace } from "vitest/config";
2 |
3 | export default defineWorkspace([
4 | {
5 | test: {
6 | name: "Browser project",
7 | browser: {
8 | enabled: true,
9 | name: 'chrome'
10 | },
11 | }
12 | }
13 | ])
--------------------------------------------------------------------------------
/test/typescript/test/vitest.custom.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | typecheck: {
6 | enabled: true,
7 | allowJs: true,
8 | include: ['**/*.test-d.*'],
9 | tsconfig: '../tsconfig.custom.json',
10 | },
11 | },
12 | })
13 |
--------------------------------------------------------------------------------
/test/ui/fixtures/sample.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, it } from 'vitest'
2 |
3 | it('add', () => {
4 | // eslint-disable-next-line no-console
5 | console.log('log test')
6 | setTimeout(() => {
7 | throw new Error('error')
8 | })
9 | setTimeout(() => {
10 | throw 1
11 | })
12 | expect(1 + 1).toEqual(2)
13 | })
14 |
--------------------------------------------------------------------------------
/packages/vitest/src/public/suite.ts:
--------------------------------------------------------------------------------
1 | export {
2 | getCurrentSuite,
3 | getCurrentTest,
4 | createTaskCollector,
5 | getFn,
6 | setFn,
7 | getHooks,
8 | setHooks,
9 | } from '@vitest/runner'
10 | export { createChainable } from '@vitest/runner/utils'
11 | export { getBenchFn, getBenchOptions } from '../runtime/benchmark'
12 |
--------------------------------------------------------------------------------
/test/cli/fixtures/fails/hook-timeout.test.ts:
--------------------------------------------------------------------------------
1 | import { beforeEach, describe, expect, it } from 'vitest'
2 |
3 | describe('hooks should timeout', () => {
4 | beforeEach(async () => {
5 | await new Promise(resolve => setTimeout(resolve, 20))
6 | }, 10)
7 | it('hello', () => {
8 | expect(true).toBe(true)
9 | })
10 | })
11 |
--------------------------------------------------------------------------------
/test/config/fixtures/mixed-environments/project/test/workspace-project.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 |
3 | test('Leaking globals not found', async () => {
4 | expect((globalThis as any).__leaking_from_workspace_project).toBe(undefined)
5 |
6 | ;(globalThis as any).__leaking_from_workspace_project = 'leaking'
7 | })
8 |
--------------------------------------------------------------------------------
/test/optimize-deps/test/web.test.ts:
--------------------------------------------------------------------------------
1 | // @vitest-environment happy-dom
2 |
3 | import { expect, test } from 'vitest'
4 |
5 | // @ts-expect-error untyped
6 | import { importMetaUrl } from '@vitest/test-dep-url'
7 |
8 | test('import.meta.url', () => {
9 | expect(importMetaUrl).toContain('/node_modules/.vite/vitest/deps/')
10 | })
11 |
--------------------------------------------------------------------------------
/test/browser/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "ESNext",
4 | "moduleResolution": "Bundler",
5 | "paths": {
6 | "#src/*": ["./src/*"]
7 | },
8 | "types": [
9 | "vite/client",
10 | "@vitest/browser/providers/playwright"
11 | ],
12 | "esModuleInterop": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/test/config/fixtures/mode/vitest.benchmark.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig((env) => {
4 | if (env.mode !== 'benchmark') {
5 | console.error('env.mode: ', env.mode)
6 | throw new Error('env.mode should be equal to "benchmark"')
7 | }
8 |
9 | return ({})
10 | })
11 |
--------------------------------------------------------------------------------
/test/core/__mocks__/@vueuse/integrations/useJwt.ts:
--------------------------------------------------------------------------------
1 | import { ref } from 'vue'
2 | import { vi } from 'vitest'
3 |
4 | export const useJwt = vi.fn(() => ({
5 | payload: ref({
6 | sub: 'login',
7 | given_name: 'firstName',
8 | family_name: 'lastName',
9 | name: 'completeName',
10 | email: 'email',
11 | }),
12 | }))
13 |
--------------------------------------------------------------------------------
/test/core/test/mocked-no-mocks-same.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test, vi } from 'vitest'
2 | import { mockedA } from '../src/mockedA'
3 |
4 | vi.mock('../src/mockedA.ts')
5 |
6 | test('testing mocking module without __mocks__ - suites don\'t conflict', () => {
7 | mockedA()
8 |
9 | expect(mockedA).toHaveBeenCalledTimes(1)
10 | })
11 |
--------------------------------------------------------------------------------
/test/core/test/snapshot-concurrent-sync.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest'
2 |
3 | // from https://github.com/vitest-dev/vitest/issues/3361
4 | describe.concurrent('concurrent suite', () => {
5 | it('snapshot', ({ expect }) => {
6 | expect({ foo: 'bar' }).toMatchSnapshot()
7 | })
8 |
9 | it('empty test')
10 | })
11 |
--------------------------------------------------------------------------------
/test/vite-node/src/main.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-console */
2 | import { a } from './testMod'
3 |
4 | console.log('[main.js] load!')
5 | console.log('[main.js] hello world')
6 | console.log('[main.js]', a)
7 |
8 | if (import.meta.hot) {
9 | import.meta.hot.accept(() => {
10 | console.log('[main.ts] hot reload!')
11 | })
12 | }
13 |
--------------------------------------------------------------------------------
/test/watch/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vitest/test-watch",
3 | "type": "module",
4 | "private": true,
5 | "scripts": {
6 | "test": "vitest"
7 | },
8 | "devDependencies": {
9 | "@vitest/browser": "workspace:*",
10 | "vite": "latest",
11 | "vitest": "workspace:*",
12 | "webdriverio": "latest"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/docs/.vitepress/components/CourseLink.vue:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/examples/basic/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2020",
4 | "module": "node16",
5 | "strict": true,
6 | "declaration": true,
7 | "declarationMap": true,
8 | "sourceMap": true,
9 | "verbatimModuleSyntax": true
10 | },
11 | "include": ["src", "test"],
12 | "exclude": ["node_modules"]
13 | }
14 |
--------------------------------------------------------------------------------
/test/cli/fixtures/list/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | include: ['basic.test.ts', 'math.test.ts'],
6 | browser: {
7 | name: 'chromium',
8 | provider: 'playwright',
9 | headless: true,
10 | api: 7523,
11 | }
12 | },
13 | })
14 |
--------------------------------------------------------------------------------
/test/config/fixtures/conditions-subpackage/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "subpackage",
3 | "private": true,
4 | "type": "module",
5 | "exports": {
6 | ".": {
7 | "custom": "./custom.js",
8 | "development": "./development.js",
9 | "production": "./production.js",
10 | "default": "./default.js"
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/test/core/test/mocking/integration.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test, vi } from 'vitest'
2 | import { createStore } from '../../src/mocks/integration'
3 |
4 | vi.mock('@vueuse/integrations/useJwt')
5 |
6 | test('Using nested modules works', () => {
7 | const { payload } = createStore()
8 |
9 | expect(payload.value.sub).toBe('login')
10 | })
11 |
--------------------------------------------------------------------------------
/test/core/test/skip-reset-state.test.ts:
--------------------------------------------------------------------------------
1 | import { getCurrentTest } from '@vitest/runner'
2 | import { afterAll, expect, test } from 'vitest'
3 |
4 | afterAll(() => {
5 | // verify "current test" resets after "skip"
6 | expect(getCurrentTest()).toBeUndefined()
7 | })
8 |
9 | test('single skipped test', ({ skip }) => {
10 | skip()
11 | })
12 |
--------------------------------------------------------------------------------
/test/typescript/fixtures/source-error/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "noEmit": true,
4 | "target": "es2020",
5 | "module": "ESNext",
6 | "moduleResolution": "Bundler",
7 | "strict": true,
8 | "verbatimModuleSyntax": true
9 | },
10 | "include": ["src", "test"],
11 | "exclude": ["node_modules"]
12 | }
13 |
--------------------------------------------------------------------------------
/test/workspaces/src/math.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable unused-imports/no-unused-vars */
2 | export function sum(a: number, b: number) {
3 | if (a === 3 && b === 4) {
4 | // This should be uncovered
5 | return 7
6 | }
7 |
8 | return a + b
9 | }
10 |
11 | function uncoveredFunction() {
12 | // This should be uncovered
13 | return 1
14 | }
15 |
--------------------------------------------------------------------------------
/examples/basic/vite.config.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | // Configure Vitest (https://vitest.dev/config/)
4 |
5 | import { defineConfig } from 'vite'
6 |
7 | export default defineConfig({
8 | test: {
9 | /* for example, use global to avoid globals imports (describe, test, expect): */
10 | // globals: true,
11 | },
12 | })
13 |
--------------------------------------------------------------------------------
/examples/preact/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Preact Example
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/examples/workspace/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2020",
4 | "module": "node16",
5 | "strict": true,
6 | "declaration": true,
7 | "declarationMap": true,
8 | "sourceMap": true,
9 | "verbatimModuleSyntax": true
10 | },
11 | "include": ["packages"],
12 | "exclude": ["node_modules"]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/vitest/src/utils/figures.ts:
--------------------------------------------------------------------------------
1 | export const F_RIGHT = '→'
2 | export const F_DOWN = '↓'
3 | export const F_UP = '↑'
4 | export const F_DOWN_RIGHT = '↳'
5 | export const F_POINTER = '❯'
6 | export const F_DOT = '·'
7 | export const F_CHECK = '✓'
8 | export const F_CROSS = '×'
9 | export const F_LONG_DASH = '⎯'
10 | export const F_RIGHT_TRI = '▶'
11 |
--------------------------------------------------------------------------------
/test/cli/fixtures/vm-threads/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | pool: 'vmThreads',
6 | css: {
7 | include: [/processed/],
8 | },
9 | server: {
10 | deps: {
11 | external: [/src\/external/],
12 | },
13 | },
14 | },
15 | })
16 |
--------------------------------------------------------------------------------
/test/core/__mocks__/zustand.ts:
--------------------------------------------------------------------------------
1 | import actualCreate from 'zustand'
2 | import { vi } from 'vitest'
3 |
4 | // when creating a store, we get its initial state, create a reset function and add it in the set
5 | const create = vi.fn((createState) => {
6 | const store = actualCreate(createState)
7 | return store
8 | })
9 |
10 | export default create
11 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/indicator-position.test.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-multiple-empty-lines */
2 | // this file should be in CRLF format
3 | import { expect, test } from 'vitest'
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | test('', async () => {
12 | expect(1 + 1).toBe(3)
13 | expect(1 + 1).toBe(2)
14 | expect(2 + 2).toBe(4)
15 | })
16 |
--------------------------------------------------------------------------------
/packages/ui/README.md:
--------------------------------------------------------------------------------
1 | # @vitest/ui
2 |
3 | This package is for UI interface of Vitest.
4 |
5 | > Work in progress.
6 |
7 | ## Development Setup
8 |
9 | At project root, create terminals with each of the following commands:
10 |
11 | ```bash
12 | nr dev
13 | ```
14 |
15 | ```bash
16 | nr test --api
17 | ```
18 |
19 | ```bash
20 | nr ui:dev
21 | ```
22 |
--------------------------------------------------------------------------------
/test/cli/fixtures/ws-server-url/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 | import basicSsl from '@vitejs/plugin-basic-ssl'
3 |
4 | // test https by
5 | // TEST_HTTPS=1 pnpm test --root fixtures/server-url --api
6 |
7 | export default defineConfig({
8 | plugins: [
9 | !!process.env.TEST_HTTPS && basicSsl(),
10 | ],
11 | })
12 |
--------------------------------------------------------------------------------
/test/core/src/wasm/wasm-bindgen-no-cyclic/index_bg.wasm.d.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable */
2 | /* eslint-disable */
3 | export const memory: WebAssembly.Memory;
4 | export function greet(a: number, b: number): void;
5 | export function __wbindgen_malloc(a: number, b: number): number;
6 | export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
7 |
--------------------------------------------------------------------------------
/test/core/test/jest-expect-no-url.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, it } from 'vitest'
2 |
3 | // simulate odd environment where URL is monkey-patched or not available
4 | it('jest-expect-no-url', () => {
5 | (globalThis as any).URL = {}
6 | expect('hello').toEqual('hello')
7 |
8 | delete (globalThis as any).URL
9 | expect('hello').toEqual('hello')
10 | })
11 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/function-as-name.bench.ts:
--------------------------------------------------------------------------------
1 | import { bench } from 'vitest'
2 |
3 | const options = {
4 | time: 0,
5 | iterations: 3,
6 | warmupTime: 0,
7 | warmupIterations: 0,
8 | }
9 |
10 | function foo() {}
11 | class Bar {}
12 |
13 | bench(foo, () => {}, options)
14 | bench(Bar, () => {}, options)
15 | bench(() => {}, () => {}, options)
16 |
--------------------------------------------------------------------------------
/test/vite-node/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | clearMocks: true,
6 | testTimeout: process.env.CI ? 120_000 : 5_000,
7 | onConsoleLog(log) {
8 | if (log.includes('Port is already')) {
9 | return false
10 | }
11 | },
12 | },
13 | })
14 |
--------------------------------------------------------------------------------
/test/workspaces-browser/src/math.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable unused-imports/no-unused-vars */
2 | export function sum(a: number, b: number) {
3 | if (a === 3 && b === 4) {
4 | // This should be uncovered
5 | return 7
6 | }
7 |
8 | return a + b
9 | }
10 |
11 | function uncoveredFunction() {
12 | // This should be uncovered
13 | return 1
14 | }
15 |
--------------------------------------------------------------------------------
/examples/fastify/src/app.ts:
--------------------------------------------------------------------------------
1 | import type { FastifyInstance } from 'fastify'
2 | import Fastify from 'fastify'
3 | import { usersData } from '../mockData'
4 |
5 | const app: FastifyInstance = Fastify({
6 | logger: process.env.NODE_ENV === 'development',
7 | })
8 |
9 | app.get('/users', async () => {
10 | return usersData
11 | })
12 |
13 | export default app
14 |
--------------------------------------------------------------------------------
/examples/solid/components/Hello.jsx:
--------------------------------------------------------------------------------
1 | import { createSignal } from 'solid-js'
2 |
3 | export function Hello(props) {
4 | const [times, setTimes] = createSignal(2)
5 | return (
6 | <>
7 | {`${props.count} x ${times()} = ${props.count * times()}`}
8 |
9 | >
10 | )
11 | }
12 |
--------------------------------------------------------------------------------
/packages/vitest/src/integrations/env/index.ts:
--------------------------------------------------------------------------------
1 | import node from './node'
2 | import jsdom from './jsdom'
3 | import happy from './happy-dom'
4 | import edge from './edge-runtime'
5 |
6 | export const environments = {
7 | node,
8 | jsdom,
9 | 'happy-dom': happy,
10 | 'edge-runtime': edge,
11 | }
12 |
13 | export const envs = Object.keys(environments)
14 |
--------------------------------------------------------------------------------
/test/benchmark/test/__snapshots__/reporter.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`summary 1`] = `
4 | "
5 |
6 | good - summary.bench.ts > suite-a
7 | (?) faster than bad
8 |
9 | good - summary.bench.ts > suite-b
10 |
11 | good - summary.bench.ts > suite-b > suite-b-nested
12 |
13 | "
14 | `;
15 |
--------------------------------------------------------------------------------
/test/browser/fixtures/mocking-watch/1_mocked-on-watch-change.test.ts:
--------------------------------------------------------------------------------
1 | import { lib } from '@vitest/cjs-lib/lib'
2 | import { vi, test, expect } from 'vitest'
3 |
4 | vi.mock(import('@vitest/cjs-lib/lib'), () => {
5 | return {
6 | lib: vi.fn(() => 'mocked')
7 | }
8 | })
9 |
10 | test('mocks correctly', () => {
11 | expect(lib()).toBe('mocked')
12 | })
13 |
--------------------------------------------------------------------------------
/test/cli/fixtures/stacktraces/add.test.ts:
--------------------------------------------------------------------------------
1 | /* body */
2 | import { expect, it } from 'vitest'
3 | import { add } from './utils'
4 |
5 | interface Num {
6 | count: number
7 | }
8 |
9 | const a: Num = { count: 10 }
10 |
11 | it('add', () => {
12 | expect(add(a.count)).toBe(100)
13 | expect(add(1)).toBe(1)
14 | return expect(add(1, 2, 3)).toBe(6)
15 | })
16 |
--------------------------------------------------------------------------------
/test/core/test/environments/custom-env.test.ts:
--------------------------------------------------------------------------------
1 | // @vitest-environment custom
2 |
3 | import { expect, test } from 'vitest'
4 |
5 | test('custom env is defined', () => {
6 | expect(expect.getState().environment).toBe('custom')
7 | expect((globalThis as any).testEnvironment).toBe('custom')
8 | expect((globalThis as any).option).toBe('config-option')
9 | })
10 |
--------------------------------------------------------------------------------
/test/core/test/environments/node.spec.ts:
--------------------------------------------------------------------------------
1 | // @vitest-environment node
2 |
3 | import { expect, test } from 'vitest'
4 |
5 | const nodeMajor = Number(process.version.slice(1).split('.')[0])
6 |
7 | test.runIf(nodeMajor > 16)('url correctly creates an object', () => {
8 | expect(() => {
9 | URL.createObjectURL(new Blob([]))
10 | }).not.toThrow()
11 | })
12 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/Vue/Counter/Counter.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 | {{ uncoveredMethod() }}
10 |
11 |
12 | {{ coveredMethod() }}
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/src/math.ts:
--------------------------------------------------------------------------------
1 | export function sum(a: number, b: number) {
2 | return a + b
3 | }
4 |
5 | export function subtract(a: number, b: number) {
6 | return a - b
7 | }
8 |
9 | export function multiply(a: number, b: number) {
10 | return a * b
11 | }
12 |
13 | export function remainder(a: number, b:number) {
14 | return a % b
15 | }
16 |
--------------------------------------------------------------------------------
/test/coverage-test/fixtures/test/merge-fixture-3.test.ts:
--------------------------------------------------------------------------------
1 | import { expect, test } from 'vitest'
2 | import { isEven } from '../src/even'
3 | import { multiply } from '../src/math'
4 |
5 | test('cover multiply again', () => {
6 | expect(multiply(20, 2)).toBe(40)
7 | })
8 |
9 | test('also cover another file', () => {
10 | expect(isEven(4)).toBe(true)
11 | })
12 |
--------------------------------------------------------------------------------
/test/reporters/fixtures/custom-error/basic.test.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'vitest';
2 |
3 | test('no name object', () => {
4 | throw { noName: 'hi' };
5 | });
6 |
7 | test('string', () => {
8 | throw "hi";
9 | });
10 |
11 | test('number', () => {
12 | throw 1234;
13 | });
14 |
15 | test('number name object', () => {
16 | throw { name: 1234 };
17 | });
18 |
--------------------------------------------------------------------------------
/test/workspaces-browser/space_browser/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineProject } from 'vitest/config'
2 |
3 | export default defineProject({
4 | test: {
5 | browser: {
6 | enabled: true,
7 | name: process.env.BROWSER || 'chrome',
8 | headless: true,
9 | provider: process.env.PROVIDER || 'webdriverio',
10 | },
11 | },
12 | })
13 |
--------------------------------------------------------------------------------
/test/workspaces/cwdPlugin.js:
--------------------------------------------------------------------------------
1 | // @ts-check
2 |
3 | export function cwdPlugin(name) {
4 | return {
5 | name: `vitest:test:workspace-${name}`,
6 | configResolved() {
7 | process.env[`${name}_CWD_CONFIG`] = process.cwd()
8 | },
9 | configureServer() {
10 | process.env[`${name}_CWD_SERVER`] = process.cwd()
11 | },
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/examples/basic/test/suite.test.ts:
--------------------------------------------------------------------------------
1 | import { assert, describe, expect, it } from 'vitest'
2 |
3 | describe('suite name', () => {
4 | it('foo', () => {
5 | assert.equal(Math.sqrt(4), 2)
6 | })
7 |
8 | it('bar', () => {
9 | expect(1 + 1).eq(2)
10 | })
11 |
12 | it('snapshot', () => {
13 | expect({ foo: 'bar' }).toMatchSnapshot()
14 | })
15 | })
16 |
--------------------------------------------------------------------------------
/packages/expect/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './jest-asymmetric-matchers'
2 | export * from './jest-utils'
3 | export * from './constants'
4 | export * from './types'
5 | export { getState, setState } from './state'
6 | export { JestChaiExpect } from './jest-expect'
7 | export { addCustomEqualityTesters } from './jest-matcher-utils'
8 | export { JestExtend } from './jest-extend'
9 |
--------------------------------------------------------------------------------
/packages/runner/src/test-state.ts:
--------------------------------------------------------------------------------
1 | import type { Custom, Test } from './types/tasks.ts'
2 |
3 | let _test: Test | Custom | undefined
4 |
5 | export function setCurrentTest(test: T | undefined): void {
6 | _test = test
7 | }
8 |
9 | export function getCurrentTest(): T {
10 | return _test as T
11 | }
12 |
--------------------------------------------------------------------------------
/test/browser/test/dialog.test.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-alert */
2 |
3 | import { expect, it } from 'vitest'
4 |
5 | it('alert', async () => {
6 | expect(alert('test')).toBeUndefined()
7 | })
8 |
9 | it('prompt', async () => {
10 | expect(prompt('test')).toBeNull()
11 | })
12 |
13 | it('confirm', async () => {
14 | expect(confirm('test')).toBe(false)
15 | })
16 |
--------------------------------------------------------------------------------