You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jason Godesky edited this page Jul 17, 2026
·
3 revisions
mockRoll mocks Foundry’s Roll class (and in particular its evaluate and evaluateSync methods) so that you can test code that uses it.
Parameters
total: number
The number that you would like the mocked Roll.total to return.
Default:1
Examples
import{beforeEach,afterEach,describe,expect,it,vi}from'vitest'import{mockRoll}from'@revolutionarygamesco/common-foundryvtt/mocks'import{roll}from'@revolutionarygamesco/common-foundryvtt'describe('mockRoll',()=>{afterEach(()=>{vi.unstubAllGlobals()})it('mocks the Roll class',async()=>{mockRoll(1)constr=newfoundry.dice.Roll('1d6')awaitr.evaluate()expect(r.total).toBe(1)})it('can be changed from test to test',()=>{mockRoll(10)expect(roll('1d6')).toBe(10)})})