Describe the bug
One dependency of a tested class has a getter of a signal. I need to mock it.
When following the guideline, it doesn't seems to compile because its a getter of a signal, which is a method.
To Reproduce
Steps to reproduce the behavior:
Create a class with a signal property:
export class DemoClass {
public get someSignal() {
return signal(10);
}
public get someOtherSignal() {
return computed(() => this.someSignal() * 2);
}
}
import { computed, signal } from '@angular/core';
import { createSpyFromClass } from 'jest-auto-spies';
describe('permissions tests', () => {
it('should compile when trying to mock signal', () => {
const classSpy = createSpyFromClass(DemoClass, { gettersToSpyOn: ['someSignal'] });
classSpy.accessorSpies.getters.someSignal.mockReturnValue(10);
});
it('should compile when trying to mock computed signal', () => {
const classSpy = createSpyFromClass(DemoClass, { gettersToSpyOn: ['someOtherSignal'] });
classSpy.accessorSpies.getters.someOtherSignal.mockReturnValue(20);
});
});
Expected behavior
It should compiles and the signal should return the mocked value
Desktop (please complete the following information):
OS: [e.g. iOS] Windows 11 pro
Browser [e.g. chrome, safari]: Chrome(but not executed in browser)
Version [e.g. 22]: 128
Additional context
The whole point is to be able to mock signal and/or computed signals. Ideally, we should have something similar than for the observable properties.
Describe the bug One dependency of a tested class has a getter of a signal. I need to mock it. When following the guideline, it doesn't seems to compile because its a getter of a signal, which is a method.
To Reproduce Steps to reproduce the behavior:
Expected behavior It should compiles and the signal should return the mocked value
Desktop (please complete the following information):
Additional context The whole point is to be able to mock signal and/or computed signals. Ideally, we should have something similar than for the observable properties.