@as-pect/core

中文文档
9.0.0发布于 2026/06/18MITTypeScriptES Module近 30 天下载 1.4万

Write AssemblyScript tests at blazing fast speeds

原始使用文档
文档目录5 节
  1. Documentation
  2. Reporter and Reporting lifecycle guidance
  3. Snapshot key format
  4. Contributors
  5. Special Thanks

jtenner/as-pect - @as-pect/core

Test Coverage Status Changesets

Write your module in AssemblyScript and get blazing fast bootstrapped tests with WebAssembly speeds!

Documentation

To view the documentation, it's located here on the gitbook. If there are any issues with the docs, please feel free to file an issue!

Reporter and Reporting lifecycle guidance

@as-pect/core owns the Test suite model, Reporting lifecycle, Suite report factory, and legacy reporter adapter. Custom reporters should prefer the report event callbacks exposed by IReporter:

  • onReportGroupStart(event) and onReportGroupFinish(event) receive { group } facts.
  • onReportTestStart(event) and onReportTestFinish(event) receive { group, test } facts.
  • onReportFinish(event) receives { report } facts for the completed suite.

These Report events carry stable Suite report facts that are ready to render. New reporters should read from SuiteGroupReport, SuiteTestReport, and SuiteReport instead of walking TestContext or mutable Test node state.

The older onEnter(ctx, node), onExit(ctx, node), and onFinish(ctx) callbacks remain available for compatibility with existing reporters and subclasses. Treat them as legacy extension points for migration only. The Reporting lifecycle now keeps compatibility-only TestContext and TestNode facts behind the legacy reporter adapter as legacy report facts so they do not leak into report event payloads.

If a reporter needs to create report facts directly, use createGroupReport(node), createTestReport(group, test), or createSuiteReport(ctx) from @as-pect/core.

Snapshot key format

@as-pect/core records snapshots under the full Test node namespace plus the explicit snapshot name passed by AssemblyScript code. The Test tree recorder creates the namespace used by the Snapshot lifecycle. A key contains each describe/it segment and duplicate-safe indexes before the snapshot name, for example:

outer[0]!~duplicate[1]!~renders value[0]

This is a breaking change from the older test-name-only snapshot keys. The namespace-derived format makes duplicate test names and repeated snapshot names deterministic because each snapshot is tied to the exact Test node that created it. Existing snapshot files should be regenerated or migrated for the next major release.

Contributors

To contribute please see CONTRIBUTING.md.

Thanks to @willemneal and @MaxGraey for all their support in making as-pect the best software it can be.

Other Contributors:

Special Thanks

Special thanks to the AssemblyScript team for creating AssemblyScript itself.

版本与发布记录

@as-pect/core 共发布 49 个版本,首次发布于 2019/07/15;过去 12 个月发布了 1 个版本。

版本发布日期距今
9.0.0latest2026/06/184 个月前
8.1.02023/04/193 年前
8.0.12022/12/133 年前
8.0.02022/11/153 年前
7.0.12022/09/014 年前
7.0.02022/09/014 年前

关于 @as-pect/core 的常见问题

@as-pect/core 是什么?

Write AssemblyScript tests at blazing fast speeds

如何安装 @as-pect/core?

在项目目录运行 npm install @as-pect/core,或使用 pnpm add / yarn add / bun add。

@as-pect/core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@as-pect/core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@as-pect/core 可以商用吗?

@as-pect/core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@as-pect/core 的下载量有多少?

根据 npm 官方下载统计,@as-pect/core 在 2026/10/07 – 2026/11/05 这 30 天内被下载 14,017 次,日均约 467 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@as-pect/core 还在维护吗?

最新版本 9.0.0 发布于 2026/06/18(4 个月前);至今共发布 49 个版本,其中过去 12 个月发布了 1 个;首次发布于 2019/07/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。