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

Function mockSessionAsync

testing/mock.ts:557–573  ·  view source on GitHub ↗
(
  func: (this: Self, ...args: Args) => Promise<Return>,
)

Source from the content-addressed store, hash-verified

555 * @returns The return value of the function.
556 */
557export function mockSessionAsync<
558 Self,
559 Args extends unknown[],
560 Return,
561>(
562 func: (this: Self, ...args: Args) => Promise<Return>,
563): (this: Self, ...args: Args) => Promise<Return> {
564 return async function (this: Self, ...args: Args): Promise<Return> {
565 const id = sessions.length;
566 sessions.push(new Set());
567 try {
568 return await func.apply(this, args);
569 } finally {
570 restore(id);
571 }
572 };
573}
574
575/**
576 * Restores all mocks registered in the current session that have not already been restored.

Callers 1

mock_test.tsFile · 0.90

Calls 2

restoreFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected