0.1.1 • Published 2 years ago

vitest-environment-drizzle v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

vitest-environment-drizzle

Vitest testing module for drizzle push and teardown scripts. See ⚡️ Vitest Environment for more details.

Actions

Setup

Environment runs drizzle-kit push:{dialect} in your application to bootstrap test database.

:warning: Be aware that this can update your production database if you are not carefull. Use this only on development and always check your .env credentials

Teardown

Environment will drop your test database depending on your adapter


Adapters

Databases supported by now:

  • mysql

Setup Environment

Example:

vite.config.ts

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    environment: 'drizzle', // Required
    environmentOptions: {
      adapter: 'mysql',
      envFile: '.env.test',
      databaseEnvName: 'DATABASE_URL'  // Optional
    }
  }
})

Environment Options

NameDescriptionDefault
adapterName database adapter. See Adaptersmysql
envFileName of the .env file for test suit.env.test
schemaPrefixPrefix to attach on the database name
databaseEnvNameThe environment variable used to store connection URLDATABASE_URL

Database Credentials

The following keys must be present on your .env.test file:

NameDescriptionExample
DATABASE_USERDatabase user credentialroot
DATABASE_PASSDatabase user password credentialroot
DATABASE_HOSTDatabase connection hostlocalhost, 127.0.0.1
DATABASE_PORTDatabase connection port3306
DATABASE_NAMEDatabase namemydb
0.1.1

2 years ago

0.1.0

2 years ago