[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Test](https://evolu.dev/docs/api-reference/common/Test) › testStubGlobal

```ts
function testStubGlobal(key: PropertyKey, value: unknown): Disposable;
```

Defined in: [packages/common/src/Test.ts:44](https://github.com/evoluhq/evolu/blob/ecbac001e0c18bbc45b44715f49ecc3a768c5ec9/packages/common/src/Test.ts#L44)

Temporarily replaces a global property for a test scope.

Node.js can mock existing globals with `t.mock.property`, but it rejects a
property that does not exist. That catches misspelled mock targets, but it
cannot model optional platform globals whose presence varies. Use this helper
to provide such a global, for example `scheduler`, or replace a global with
`undefined` to exercise a fallback.

The original property descriptor is restored on disposal. A property that did
not exist is deleted. Prefer dependency injection when available because
global properties are shared by concurrently running tests.

### Example

```ts

const key = Symbol("test global");
{
  using _stub = testStubGlobal(key, 42);
  assertEqual(Reflect.get(globalThis, key), 42);
}
assertFalse(Reflect.has(globalThis, key));
```