JSPM

vitest

0.0.11
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16529047
  • Score
    100M100P100Q205466F
  • License MIT

Package Exports

  • vitest

Readme

vitest

NPM version

A blazing fast test runner powered by Vite.

Features

  • Vite's config, transformers, resolvers, and plugins. Powered by vite-node
  • Jest Snapshot
  • Chai for assertions
  • Sinon for mocking
  • Async suite / test, top level await
  • ESM friendly
  • Out-of-box TypeScript support
  • Suite and Test filtering (skip, only, todo)
import { it, describe, expect, assert } from 'vitest'

describe('suite name', () => {
  it('foo', () => {
    assert.equal(Math.sqrt(4), 2)
  })

  it('bar', () => {
    expect(1 + 1).eq(2)
  })

  it('snapshot', () => {
    expect({ foo: 'bar' }).toMatchSnapshot()
  })
})
$ npx vitest

Filtering

Skipping suites and tasks

Use .skip to avoid running certain suites or tests

describe.skip('skipped suite', () => {
  it('task', () => {
    // Suite skipped, no error
    assert.equal(Math.sqrt(4), 3)
  })
})

describe('suite', () => {
  it.skip('skipped task', () => {
    // Task skipped, no error
    assert.equal(Math.sqrt(4), 3)
  })
})

Selecting suites and tests to run

Use .only to only run certain suites or tests

// Only this suite (and others marked with only) are run
describe.only('suite', () => {
  it('task', () => {
    assert.equal(Math.sqrt(4), 3) 
  })
})

describe('another suite', () => {
  it('skipped task', () => {
     // Task skipped, as tests are running in Only mode
    assert.equal(Math.sqrt(4), 3)
  })

  it.only('task', () => {
     // Only this task (and others marked with only) are run
    assert.equal(Math.sqrt(4), 2)
  })
})

Unimplemented suites and tests

Use .todo to stub suites and tests that should be implemented

 // An entry will be shown in the report for this suite
describe.todo('unimplemented suite')

// An entry will be shown in the report for this task
describe('suite', () => {
  it.todo('unimplemented task')
})

TODO

  • Reporter & Better output
  • Task filter
  • Mock
  • Parallel Executing
  • CLI Help
  • JSDom
  • Watch
  • Coverage

Sponsors

License

MIT License © 2021 Anthony Fu