Skip to content

mockHooks

Jason Godesky edited this page Aug 2, 2026 · 1 revision

mockHooks mocks Foundry’s Hooks class to help you test your hooks.

Examples

import { describe, it, expect } from 'vitest'
import { mockHooks } from '@revolutionarygamesco/common-foundryvtt/mocks'

describe('testRun', () => {
  it('runs the hook', () => {
     const hooks = mockHooks()
     Hooks.on('someEvent', (a: number) => {})
     Hooks.call('someEvent', 42)
    expect(hooks.call).toHaveBeenCalledWith('someEvent', 42)
  })
})

Clone this wiki locally