Skip to content

@vttforge/testing / index / MockFoundryOptions

Interface: MockFoundryOptions ​

Properties ​

actors? ​

optional actors?: readonly MockWorldDocument[]

The documents the world holds.

Each collection answers get, getName, find, filter, size and iteration, so code that reads a world reads this the way it reads Foundry. createMockActor and createMockItem build entries with flags and update already on them; a plain object works too.

ts
withMockFoundry({ items: [createMockItem({ id: 'a', name: 'Sword' })] });

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() } },
});

items? ​

optional items?: readonly MockWorldDocument[]


journal? ​

optional journal?: readonly MockWorldDocument[]


modules? ​

optional modules?: readonly MockModuleOptions[]

The modules installed in this world.

game.modules.get(id) invents a handle for any id the code under test names, which is enough for a package reading its own. Code that walks the list, an update checker or a report, needs one to walk: name them here.

ts
withMockFoundry({
  modules: [{ id: 'other-module', version: '1.2.0', url: 'https://…' }],
});

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.