SuperAPI AI 工具集

testing

测试与质量

查看项目

更新于 10-15 20:27

技能介绍

用途:该技能说明 contentstack-cli-tsgen 项目的测试运行方式与环境变量配置,覆盖单元测试、集成测试和 CI 流程。

主要命令:npm test 使用 Jest 并带 --testPathPattern=tests,随后 posttest 运行 ESLint(定义于 package.json);npm run test:integration 仅对 tests/integration 运行 Jest;npm run prepack 构建 lib/,在本地 csdx plugins:link 类工作流前必须执行。

配置:jest.config.js 使用 ts-jest,testEnvironment 为 node。

集成测试:tests/integration/tsgen.integration.test.ts 会以 TOKEN_ALIAS 启动 csdx tsgen,并通过 dotenv 从包根目录加载 .env(路径相对测试文件)。TOKEN_ALIAS 必须定义,否则测试套件在加载时抛出错误。

CI:.github/workflows/node.js.yml 依次执行 npm ci、可选的 npm run build --if-present、全局安装 @contentstack/cli、csdx config:set:region、csdx auth:tokens:add(delivery)、npm run prepack、csdx plugins:link,最后以 TOKEN_ALIAS secret 运行 npm test。

限制:资料未提供具体测试用例内容、覆盖率要求或失败排查细节。