Documentation / zerotal / commands / TestCommand
Class: TestCommand
Defined in: packages/core/src/command/builtin/TestCommand.ts:26
bun zt test [pattern] [flags] — runs the test suite in the test environment.
Wraps bun test with proper app-environment setup:
- Sets APP_ENV=test before spawning so config loads correctly.
- Passes ZT_DB_URL to the child process; the @zerotal/testing/preload module reads it and wires up the DB connection before each test file runs, so withDatabase() and DB.table() work without manual beforeAll boilerplate.
- If @zerotal/testing is not installed the preload is silently skipped — tests that use createTestApp() still work without it.
All positional args and recognised flags are forwarded to bun test.
Example
bun zt test # run all tests
bun zt test src/models # filter by path
bun zt test --coverage # with coverage
bun zt test --watch # watch mode
Extends
Constructors
Constructor
new TestCommand():
TestCommand
Returns
TestCommand
Inherited from
Properties
_writer
_writer:
OutputWriter
Defined in: packages/core/src/command/Command.ts:71
Output destination. Replaced with BufferWriter by Artisan.call().
Inherited from
args
args:
Record<string,string> ={}
Defined in: packages/core/src/command/Command.ts:74
Parsed positional arguments — set by CommandRunner before run().
Inherited from
flags
flags:
Record<string,string|boolean|number> ={}
Defined in: packages/core/src/command/Command.ts:76
Parsed flags — set by CommandRunner before run().
Inherited from
app
app:
unknown=undefined
Defined in: packages/core/src/command/Command.ts:78
Application instance — set by CommandRunner when needsApp is true.
Inherited from
commandName
staticcommandName:string="test"
Defined in: packages/core/src/command/builtin/TestCommand.ts:27
Overrides
description
staticdescription:string="Run the test suite in test environment"
Defined in: packages/core/src/command/builtin/TestCommand.ts:28
Overrides
needsApp
staticneedsApp:boolean=false
Defined in: packages/core/src/command/builtin/TestCommand.ts:29
Overrides
args
staticargs:object[]
Defined in: packages/core/src/command/builtin/TestCommand.ts:31
name
name:
string="pattern"
required
required:
boolean=false
default
default:
string=""
Overrides
flags
staticflags: ({short?:undefined;name:string;type:"boolean";description:string;default:boolean; } | {name:string;short:string;type:"boolean";description:string;default:boolean; } | {short?:undefined;name:string;type:"number";description:string;default:number; })[]
Defined in: packages/core/src/command/builtin/TestCommand.ts:33
Overrides
Methods
info()
info(
msg):void
Defined in: packages/core/src/command/Command.ts:82
Parameters
msg
string
Returns
void
Inherited from
error()
error(
msg):void
Defined in: packages/core/src/command/Command.ts:85
Parameters
msg
string
Returns
void
Inherited from
warn()
warn(
msg):void
Defined in: packages/core/src/command/Command.ts:88
Parameters
msg
string
Returns
void
Inherited from
line()
line(
msg):void
Defined in: packages/core/src/command/Command.ts:91
Parameters
msg
string
Returns
void
Inherited from
dim()
dim(
msg):void
Defined in: packages/core/src/command/Command.ts:94
Parameters
msg
string
Returns
void
Inherited from
write()
write(
msg):void
Defined in: packages/core/src/command/Command.ts:97
Parameters
msg
string
Returns
void
Inherited from
newLine()
newLine():
void
Defined in: packages/core/src/command/Command.ts:100
Returns
void
Inherited from
section()
section(
title):void
Defined in: packages/core/src/command/Command.ts:103
Parameters
title
string
Returns
void
Inherited from
table()
table(
rows,indent?):void
Defined in: packages/core/src/command/Command.ts:106
Parameters
rows
[string, string][]
indent?
number = 2
Returns
void
Inherited from
ask()
ask(
question,defaultValue?):Promise<string>
Defined in: packages/core/src/command/Command.ts:127
Prompt the user for text input and wait for Enter.
Parameters
question
string
defaultValue?
string
Returns
Promise<string>
Example
const name = await this.ask('What is your name?');
const env = await this.ask('Environment?', 'production');
Inherited from
confirm()
confirm(
question,defaultValue?):Promise<boolean>
Defined in: packages/core/src/command/Command.ts:142
Prompt the user for a yes/no confirmation. Returns true for y/yes, false otherwise.
Parameters
question
string
defaultValue?
boolean = false
Returns
Promise<boolean>
Example
const ok = await this.confirm('Run migrations?');
const ok = await this.confirm('Overwrite file?', true);
Inherited from
choice()
choice(
question,options):Promise<string>
Defined in: packages/core/src/command/Command.ts:157
Prompt the user to select one option from a numbered list. Returns the selected string. Defaults to the first option on invalid input.
Parameters
question
string
options
string[]
Returns
Promise<string>
Example
const env = await this.choice('Environment:', ['local', 'staging', 'production']);
Inherited from
secret()
secret(
question):Promise<string>
Defined in: packages/core/src/command/Command.ts:170
Parameters
question
string
Returns
Promise<string>
Inherited from
_readLine()
_readLine():
Promise<string>
Defined in: packages/core/src/command/Command.ts:213
Read one line from stdin. Override in tests to avoid blocking.
Returns
Promise<string>
Inherited from
run()
run():
Promise<void>
Defined in: packages/core/src/command/builtin/TestCommand.ts:67
Returns
Promise<void>