In such a situation, without rewriting your logic for using named functions, you really have no choice but to declare the function before the test , for example
const foo = i => j => i * j
const foo2 = foo(2)
const bar = () => ({ baz: foo2, boz: 1 })
describe('Test anonymous function equality', () => {
it('+++ bar', () => {
const obj = bar()
expect(obj).toEqual({ baz: foo2, boz: 1 })
});
});
Alternatively, you can verify that obj.bar any function using expect.any(Function):
expect(obj).toEqual({ baz: expect.any(Function), boz: 1 })
which may make sense depending on the context of the test.