# 在配置的路径中未找到测试结果。请确保您的测试将 JUnit XML 报告输出到指定目录。

- **ID:** `cicd/circleci-no-test-results`
- **领域:** cicd
- **类别:** test_error
- **错误码:** `TEST_RESULTS_MISSING`
- **验证级别:** ai_generated
- **修复率:** 87%

## 根因

CircleCI 的测试报告步骤找不到 JUnit XML 文件，因为测试框架未配置生成它们、输出路径不正确或测试尚未运行。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| CircleCI CLI 0.1.28000 | active | — | — |
| CircleCI Server v4.1 | active | — | — |
| Jest 29.7.0 | active | — | — |
| pytest 7.4.0 | active | — | — |

## 解决方案

1. ```
   配置测试框架以输出 JUnit XML：对于 Jest，添加 `jest --ci --reporters=default --reporters=jest-junit` 并设置 `JEST_JUNIT_OUTPUT_DIR=test-results/jest`。对于 pytest，使用 `pytest --junitxml=test-results/pytest/results.xml`。
   ```
2. ```
   更新 CircleCI 配置以匹配实际输出路径：如果 XML 文件生成在 `test-results/jest` 中，则使用 `- store_test_results: path: test-results/jest`。
   ```
3. ```
   运行调试步骤列出文件：`- run: find . -name "*.xml" -type f` 以在 store_test_results 之前验证测试结果是否存在。
   ```

## 无效尝试

- **** — Changing the store_test_results path to a random directory without generating XML files; the step still finds nothing. (80% 失败率)
- **** — Disabling the store_test_results step entirely; this removes test reporting but the underlying issue (no XML generation) remains for other steps. (70% 失败率)
- **** — Assuming the test framework generates XML by default; many frameworks (e.g., pytest, Jest) require explicit configuration. (60% 失败率)
