Skip to content

@vttforge/testing / MockFoundryOptions

Interface: MockFoundryOptions

Properties

foundry?

optional foundry?: Record<string, unknown>

Extra foundry.* members, merged over the defaults.


game?

optional game?: Record<string, unknown>

Extra game.* members, merged over the defaults.


globals?

optional globals?: Record<string, unknown>

Any other globals your code reads, installed for the life of the mock and removed by restore() along with the rest.

Foundry puts each document class on the global scope, and code under test reaches for them by name: Actor.create, JournalEntry.create, ChatMessage.getSpeaker. Those are not part of the fixed set this helper installs, so name the ones you need.

ts
withMockFoundry({
  globals: { JournalEntry: { create: vi.fn() } },
});

user?

optional user?: object

The current user. Defaults to a GM, since most module code checks.

id?

optional id?: string

isGM?

optional isGM?: boolean

name?

optional name?: string

MIT licensed.