MCPcopy Create free account
hub / github.com/angular/angular / wrapTestInZone

Function wrapTestInZone

packages/zone.js/lib/vitest/vitest.ts:91–107  ·  view source on GitHub ↗

* Gets a function wrapping the body of a vitest `it/beforeEach/afterEach` block to * execute in a ProxyZone zone. * This will run in the `proxyZone`.

(testBody: Function)

Source from the content-addressed store, hash-verified

89 * This will run in the `proxyZone`.
90 */
91 function wrapTestInZone(testBody: Function): Function {
92 if (typeof testBody !== 'function') {
93 return testBody;
94 }
95 const wrappedFunc = function () {
96 return proxyZone.run(testBody, null, arguments as any);
97 };
98 // Update the length of wrappedFunc to be the same as the length of the testBody
99 // So vitest core can handle whether the test function has `done()` or not correctly
100 Object.defineProperty(wrappedFunc, 'length', {
101 configurable: true,
102 writable: true,
103 enumerable: false,
104 });
105 wrappedFunc.length = testBody.length;
106 return wrappedFunc;
107 }
108
109 /** Patch functions with modifiers (i.e. `describe`/`it`). */
110 function patchFnWithModifiers(methodName: string, wrapFn: (fn: Function) => Function) {

Callers 1

patchVitestFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected