MCPcopy
hub / github.com/jestjs/jest / installErrorOnPrivate

Function installErrorOnPrivate

packages/jest-jasmine2/src/errorOnPrivate.ts:41–76  ·  view source on GitHub ↗
(global: Global.Global)

Source from the content-addressed store, hash-verified

39};
40
41export function installErrorOnPrivate(global: Global.Global): void {
42 const jasmine = global.jasmine;
43
44 for (const functionName of Object.keys(
45 disabledGlobals,
46 ) as Array<DisabledGlobalKeys>) {
47 global[functionName] = () => {
48 throwAtFunction(disabledGlobals[functionName], global[functionName]);
49 };
50 }
51
52 for (const methodName of Object.keys(
53 disabledJasmineMethods,
54 ) as Array<DisabledJasmineMethodsKeys>) {
55 // @ts-expect-error - void unallowd, but it throws 🤷
56 jasmine[methodName] = () => {
57 throwAtFunction(disabledJasmineMethods[methodName], jasmine[methodName]);
58 };
59 }
60
61 function set() {
62 throwAtFunction(
63 'Illegal usage of `jasmine.DEFAULT_TIMEOUT_INTERVAL`, prefer `jest.setTimeout`.',
64 set,
65 );
66 }
67
68 const original = jasmine.DEFAULT_TIMEOUT_INTERVAL;
69
70 Object.defineProperty(jasmine, 'DEFAULT_TIMEOUT_INTERVAL', {
71 configurable: true,
72 enumerable: true,
73 get: () => original,
74 set,
75 });
76}
77
78function throwAtFunction(
79 message: string,

Callers 1

jasmine2Function · 0.90

Calls 2

throwAtFunctionFunction · 0.85
definePropertyMethod · 0.80

Tested by

no test coverage detected