diff --git a/packages/loot-core/src/server/accounts/rules.test.ts b/packages/loot-core/src/server/accounts/rules.test.ts index c0d191e42fb..859d7ab7e71 100644 --- a/packages/loot-core/src/server/accounts/rules.test.ts +++ b/packages/loot-core/src/server/accounts/rules.test.ts @@ -397,6 +397,17 @@ describe('Action', () => { testHelper('{{year "2002-07-25"}}', '2002'); testHelper('{{format "2002-07-25" "MM yyyy d"}}', '07 2002 25'); }); + + test('{{debug}} should log the item', () => { + const action = new Action('set', 'notes', '', { + template: '{{debug notes}}', + }); + const item = { notes: 'Sarah' }; + const spy = jest.spyOn(console, 'log').mockImplementation(); + action.exec(item); + expect(spy).toHaveBeenCalledWith('Sarah'); + spy.mockRestore(); + }); }); }); diff --git a/packages/loot-core/src/server/accounts/rules.ts b/packages/loot-core/src/server/accounts/rules.ts index 0be4b81513a..ef6c78decab 100644 --- a/packages/loot-core/src/server/accounts/rules.ts +++ b/packages/loot-core/src/server/accounts/rules.ts @@ -75,6 +75,9 @@ function registerHandlebarsHelpers() { month: (date: string) => format(date, 'M'), year: (date: string) => format(date, 'yyyy'), format: (date: string, f: string) => format(date, f), + debug: (value: unknown) => { + console.log(value); + }, }; for (const [name, fn] of Object.entries(helpers)) {