Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.
/ vitest-ts Public archive

Support vitest transform typescript to commonjs

License

Notifications You must be signed in to change notification settings

xn-sakina/vitest-ts

Repository files navigation

vitest-ts

Support vitest transform typescript to commonjs

Motivation

vitest is ESM first, cannot handle scene where output is commonjs format, we need to manually convert esm to cjs in the test time.

Install

  pnpm add -D vitest-ts

Usage

commonjs scene

// vitest.config.ts

import { createVitestConfig } from 'vitest-ts'

export default createVitestConfig()({
  // ↓ your vitest config
  test: {
    include: ['./src/**/*.test.ts'],
  },
})

react scene

// vitest.config.ts

import { createVitestConfig } from 'vitest-ts'

export default createVitestConfig({
  target: 'browser',
})({
  // ↓ your vitest config
  test: {
    include: ['./src/**/*.test.{ts,tsx}'],
  },
})

License

MIT