@endo/ses-ava

中文文档
1.4.2发布于 2026/06/12Apache-2.0ES Module近 30 天下载 1.6万

Virtualize AVA's test to work better under SES.

原始使用文档

@endo/ses-ava

SES-AVA wraps AVA test functions and initializes the SES-shim with options suitable for debugging tests. This includes logging errors to the console with

  • deep stacks of prior turns
  • unredacted stack traces
  • unredacted error messages

To use this module, in your AVA test files, replace

import 'ses'; // or however you initialize the SES-shim
import test from 'ava';

with

import test from '@endo/ses-ava/prepare-endo.js';

and add

  "devDependencies": {
    // ...
    "@endo/ses-ava": "...", // for the current version of @endo/ses-ava
    // ...
  },

specifically to "devDependencies". @endo/ses-ava itself depends on AVA as a regular dependency, so it you include @endo/ses-ava as a regular dependency, bundlers might bundle your code with all of AVA.

SES-AVA rhymes with Nineveh.

Supporting multiple configurations

SES-AVA also provides a command line tool, ses-ava, that can run AVA with multiple configurations in a single command, intercepting flags to filter for interesting configurations. The ses-ava command consumes the "ava" and (new) "sesAvaConfigs" properties in package.json to discover and name the supported configurations which can be referenced by --only and --exclude options (and their respective -o and -x shorthands), where the "ava" configuration is the default, if present.

With appropriate configurations, packages can run many of the same tests with or without an initialized Endo environment. This is useful for Endo's Hardened Modules: modules that use harden to defend the integrity of their interface, with varying degrees of defense depending on whether they're used in composition with HardenedJS's lockdown.

For tests that might be used regardless of the environment, SES-AVA provides an @endo/ses-ava/test.js module. It exports the test from ava by default. But with the node condition ses-ava:endo, it exports a wrapped test that unredacts errors, so tests see the original error messages that would otherwise be redacted by SES's Assert machinery.

import test from '@endo/ses-ava/test.js';

SES-AVA then enables different AVA configurations to set up different environments. For example, the lockdown configuration might look like:

export default {
  require: ['@endo/ses-ava/prepare-endo-config.js'],
  nodeArguments: ['-C', 'ses-ava:endo']
};

This relies on SES-AVA to initialize an Endo environment, including the SES shims and Eventual Send shim, and also register the SES-AVA wrapped test declarator, which can unredact error messages produced by the Assert shim from SES. If the test doesn't import @endo/ses-ava/test.js, requiring @endo/ses-ava/prepare-endo-config.js ensures the environment is fully initialized. In the root of the Endo repository, look at the ava-*.config.mjs modules for example configurations.

Then, in package.json, we can use ses-ava instead of ava.

{
  "scripts": {
    "test": "ses-ava",
    "test:c8": "c8 ${C8_OPTIONS:-} ses-ava"
  },
  "avaConfigs": {
    "lockdown": "test/_ava-lockdown.config.mjs",
    "unsafe": "test/_ava-lockdown-unsafe.config.mjs",
  }
}

With this configuration, ses-ava ...args --exclude lockdown and ses-ava ...args --only unsafe would both just run the unsafe configuration. Using ses-ava under c8 allows all configurations to cover used code.

Compatibility

If you were already using @endo/ses-ava by doing

import 'ses'; // or however you initialize the SES-shim
import rawTest from 'ava';
import { wrapTest } from '@endo/ses-ava';

const test = wrapTest(rawTest);

that code will continue to work. But it should be upgraded to the above pattern if possible.

版本与发布记录

@endo/ses-ava 共发布 66 个版本,首次发布于 2021/06/02;过去 12 个月发布了 3 个版本。

版本发布日期距今
1.4.2latest2026/06/125 个月前
1.4.12026/04/176 个月前
1.4.02026/02/278 个月前
1.3.22025/07/121.3 年前
1.3.12025/06/181.4 年前
1.3.02025/06/031.4 年前

关于 @endo/ses-ava 的常见问题

@endo/ses-ava 是什么?

Virtualize AVA's test to work better under SES.

如何安装 @endo/ses-ava?

在项目目录运行 npm install @endo/ses-ava,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 ses-ava,可以用 npx ses-ava 直接运行。

@endo/ses-ava 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/endo__ses-ava 是否存在。

@endo/ses-ava 支持 ESM 还是 CommonJS?

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

@endo/ses-ava 可以商用吗?

@endo/ses-ava 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@endo/ses-ava 的下载量有多少?

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

@endo/ses-ava 还在维护吗?

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