Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"all": true,
"src": ["src"],
"include": ["src/**/*.ts"],
"exclude": ["src/**/*.d.ts"],
"exclude-after-remap": true,
"reporter": ["text", "html", "lcov", "json", "json-summary"],
"reports-dir": "codex_artifact/coverage",
"check-coverage": true,
"lines": 96,
"branches": 87,
"functions": 98,
"statements": 96
}
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
examples/data/brain-drummyfish.obj -text
examples/data/synthetic-air-quality.json -text
examples/data/stereo-spectrum-demo.json -text
docs/api-test-map.json linguist-generated=true
docs/api-test-map.md linguist-generated=true
30 changes: 26 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,34 @@ jobs:
run: npm ci
- name: 检查类型
run: npm run typecheck
- name: 运行单元测试
run: npm test
- name: 检查 OpenTest 接口兼容性
run: npm run test:opentest-contract
- name: 运行单元测试和 OpenTest 合同并检查覆盖率
run: npm run test:coverage
- name: 检查公开 API、字段和常量的功能场景及断言映射
run: npm run test:api
- name: 构建库和示例
run: npm run build
- name: 保存代码覆盖率报告
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: |
codex_artifact/coverage/
!codex_artifact/coverage/tmp/**
if-no-files-found: warn
retention-days: 14
- name: 保存 API 测试映射和执行报告
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: api-test-map
path: |
docs/api-test-map.json
docs/api-test-map.md
docs/api-test-policy.json
codex_artifact/api-tests/
if-no-files-found: warn
retention-days: 14

browser:
name: CRYChart browser tests
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,21 @@ The package provides ES modules, CommonJS, a browser script, and TypeScript decl
npm run typecheck
npm test
npm run test:opentest-contract
npm run test:coverage
npm run test:api
npm run build
npm run test:browser
npm run test:gallery
```

`npm run test:coverage` runs both unit tests and OpenTest API contracts. c8/V8 measures all `src/**/*.ts` except `.d.ts` files. Coverage runs execute source modules through tsx without bundling or tree shaking, so uncalled functions remain measurable. Examples, test infrastructure and UI automation are outside this coverage scope.

CI and `npm run verify` enforce at least 96% line and statement coverage, 87% branch coverage and 98% function coverage, configured in `.c8rc.json`. Thresholds use CI's Node 22/V8 baseline; coverage may differ across Node major versions. Reports are written to `codex_artifact/coverage/`: `index.html`, `lcov.info`, `coverage-final.json` and `coverage-summary.json`. CI uploads the `code-coverage` artifact for 14 days, including generated reports when tests or coverage thresholds fail.

The [public API test inventory](docs/api-test-map.md) and `docs/api-test-map.json` link entrypoints to functional scenarios and assertion expressions. Entries distinguish `mapped`, `missing`, `placeholder` and `type-only`; a mapping does not establish every parameter combination or certify browser behavior.

Run `npm run test:coverage` followed by `npm run test:api`. The API gate checks passing, current-source test results, declarations, scenario references and retained assertions. All non-placeholder callable APIs, public fields and constants require asserted scenarios, including inherited members, factories and constructor-assigned `engine` objects. `publicValues`, `mappedValues` and `unassertedValues` report total, mapped and missing public values; CI requires `unassertedValues` to be zero. New fields, constants and APIs need scenarios before the map can be updated, and updating cannot erase existing value coverage. After intentional API or test changes, run `npm run api:map:update` and review the diff. Placeholder explanations and partial implementation limits are in `docs/api-test-policy.json`. CI uploads the `api-test-map` artifact for 14 days.

Browser tests use an installed, visible Chrome browser. Data and API tests do not replace visual, interaction, or performance tests. Performance results apply only to the recorded data volume, plot area, device pixel ratio, and machine configuration.

## License
Expand Down
10 changes: 10 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,21 @@ context.dispose()
npm run typecheck
npm test
npm run test:opentest-contract
npm run test:coverage
npm run test:api
npm run build
npm run test:browser
npm run test:gallery
```

`npm run test:coverage` 合并运行单元测试和 OpenTest 接口合同,用 c8/V8 统计全部 `src/**/*.ts`(不含 `.d.ts`)。覆盖率模式通过 tsx 直接执行源码,避免打包裁剪未调用函数;示例、测试驱动和 UI 自动化不计入该代码覆盖率。

CI 和 `npm run verify` 均要求行覆盖率和语句覆盖率至少 96%、分支至少 87%、函数至少 98%,任一不足即失败。门槛配置在 `.c8rc.json`,以 CI 的 Node 22/V8 统计口径为准;不同 Node 主版本的覆盖率可能不同。HTML 报告为 `codex_artifact/coverage/index.html`,同时生成 `lcov.info`、`coverage-final.json` 和 `coverage-summary.json`;CI 的 `code-coverage` 附件保留 14 天,测试或门槛失败时也会上传已生成的报告。

公开 API 到场景、断言的完整盘点见 [API 测试清单](docs/api-test-map.md),机器可读版本为 `docs/api-test-map.json`。清单区分 `mapped`(有可追溯调用/显式绑定和断言)、`missing`(尚未绑定有效场景)、`placeholder`(兼容占位或有意为空的钩子)、`type-only`(类型声明)。绑定一个场景不表示该 API 的全部参数组合均已验证,浏览器用例不借用单元测试结果认证。

先运行 `npm run test:coverage`,再运行 `npm run test:api`,后者会核验本轮测试实际通过、源码指纹未变化、API 签名和测试引用有效、原有断言未被移除。所有非占位的可调用接口、公开字段和常量均要求有断言场景,包括继承成员、工厂方法和构造函数中赋值的 `engine` 对象。`publicValues`、`mappedValues`、`unassertedValues` 分别统计公开值总数、有场景映射及缺失映射的数量;CI 要求 `unassertedValues` 为零。新增字段/常量和 API 必须补场景后才允许更新清单,已有值映射也不能被更新命令抹除。修改测试或公开签名后,运行 `npm run api:map:update` 并审核清单差异;占位及部分实现的限制在 `docs/api-test-policy.json`。CI 上传 `api-test-map` 附件,保留 14 天。

浏览器测试使用已安装的可见 Chrome。数据和接口测试不能替代图像、交互及性能测试。性能结果只适用于记录中的数据量、绘图区、设备像素比和机器配置。

## 许可协议
Expand Down
Loading
Loading