MCPcopy Create free account
hub / github.com/denoland/std / addHook

Function addHook

testing/bdd.ts:824–841  ·  view source on GitHub ↗
(
  name: HookNames,
  fn: (this: T) => void | Promise<void>,
)

Source from the content-addressed store, hash-verified

822};
823
824function addHook<T>(
825 name: HookNames,
826 fn: (this: T) => void | Promise<void>,
827) {
828 if (!TestSuiteInternal.current) {
829 if (TestSuiteInternal.started) {
830 throw new Error(
831 "Cannot add global hooks after a global test is registered",
832 );
833 }
834 TestSuiteInternal.current = new TestSuiteInternal({
835 name: "global",
836 [name]: fn,
837 });
838 } else {
839 TestSuiteInternal.setHook(TestSuiteInternal.current!, name, fn);
840 }
841}
842
843/**
844 * Run some shared setup before all of the tests in the group.

Callers 4

beforeAllFunction · 0.85
afterAllFunction · 0.85
beforeEachFunction · 0.85
afterEachFunction · 0.85

Calls 1

setHookMethod · 0.80

Tested by

no test coverage detected