afterEach([fn][, options])
-
fn
<Function> | <AsyncFunction> 钩子函数。如果钩子使用回调,则回调函数作为第二个参数传入。默认值:空操作函数。¥
fn
<Function> | <AsyncFunction> The hook function. If the hook uses callbacks, the callback function is passed as the second argument. Default: A no-op function. -
options
<Object> 钩子的配置选项。支持以下属性:¥
options
<Object> Configuration options for the hook. The following properties are supported:-
signal
<AbortSignal> 允许中止正在进行的钩子。¥
signal
<AbortSignal> Allows aborting an in-progress hook. -
timeout
<number> 钩子会在几毫秒后失败。如果未指定,则子测试从其父测试继承此值。默认值:Infinity
。¥
timeout
<number> A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. Default:Infinity
.
-
该函数创建一个钩子,在当前套件中的每个测试之后运行。即使测试失败,afterEach()
钩子也会运行。
¥This function creates a hook that runs after each test in the current suite.
The afterEach()
hook is run even if the test fails.
describe('tests', async () => {
afterEach(() => console.log('finished running a test'));
it('is a subtest', () => {
assert.ok('some relevant assertion here');
});
});