afterEach([, fn][, options])


  • fn <Function> | <AsyncFunction> 钩子函数。如果钩子使用回调,则回调函数作为第二个参数传入。默认值: 一个空操作函数。
  • options <Object> 钩子的配置选项。支持以下属性:
    • signal <AbortSignal> 允许中止正在进行的钩子。
    • timeout <number> 钩子将在指定毫秒数后失败。如果未指定,子测试将继承父测试的此值。默认值: Infinity

此函数用于创建一个钩子,在当前测试的每个子测试之后运行。

【This function is used to create a hook running after each subtest of the current test.】

describe('tests', async () => {
  afterEach(() => t.diagnostic('about to run a test'));
  it('is a subtest', () => {
    assert.ok('some relevant assertion here');
  });
});