nb source test

在选中应用目录中运行测试。执行测试前,CLI 会重新创建一个内置 Docker 测试数据库,并注入内部使用的 DB_* 环境变量。

用法

nb source test [paths...] [flags]

参数

参数类型说明
[paths...]string[]透传给测试运行器的测试文件路径或 glob
--cwd, -cstring运行测试的应用目录,默认当前目录
--watch, -wboolean以 watch 模式运行 Vitest
--runboolean单次运行,不进入 watch 模式
--allowOnlyboolean允许 .only 测试
--bailboolean首次失败后停止
--coverageboolean启用覆盖率报告
--single-threadstring透传 single-thread 模式给底层测试运行器
--serverboolean强制服务端测试模式
--clientboolean强制客户端测试模式
--db-clean, -dboolean在底层应用命令支持时清理数据库
--db-dialectstring内置测试数据库类型:postgresmysqlmariadbkingbase
--db-imagestring内置测试数据库 Docker 镜像
--db-portstring内置测试数据库发布到宿主机的 TCP 端口
--db-databasestring注入测试使用的数据库名
--db-userstring注入测试使用的数据库用户
--db-passwordstring注入测试使用的数据库密码
--verboseboolean显示底层 Docker 和测试运行器输出

示例

nb source test
nb source test --cwd /path/to/app
nb source test packages/core/server/src/__tests__/foo.test.ts
nb source test --server --coverage
nb source test --db-port 5433

相关命令