用途:为 InfluxData 文档站点运行、验证和分析 Cypress 端到端测试,并指导理解 Hugo 何时自动启动、解读测试结果与调试失败。
主要能力:测试运行器 run-e2e-specs.js 自动管理 Hugo,测试使用 1315 端口(非 1313);端口空闲则自动启动 Hugo,被占用则检查是否为可用 Hugo 服务器并复用,日志写入 /tmp/hugo_server.log。支持内容文件映射到 URL 的测试、功能测试(--no-mapping)以及复用已有 Hugo 服务器加速迭代。
必要用法:先执行 yarn install,并用 yarn cypress --version 验证。测试内容文件:node cypress/support/run-e2e-specs.js content/path/to/file.md;指定 spec:node cypress/support/run-e2e-specs.js --spec "cypress/e2e/content/spec.cy.js" content/path/to/file.md;功能测试:node cypress/support/run-e2e-specs.js --spec "cypress/e2e/page-context.cy.js" --no-mapping;短代码示例:yarn test:shortcode-examples。API 参考测试需先运行 yarn build:api-docs 生成内容,否则 404;Markdown 校验测试需先 npx hugo --quiet 再 yarn build:md。手动启动 Hugo:npx hugo server --port 1315 --environment testing --noHTTPCache。
适用场景:内容页面校验、API 参考页、页面上下文与导航、Markdown 生成、JSON-LD 结构化数据断言、链接有效性检查等。
限制:Cypress 仅证明标记在预期位置输出,不校验 schema 正确性,需用 validator.schema.org(非 Google Rich Results Test)。CI 中禁用视频、超时增大。资料未提供收费、价格与平台信息。